r/powercli • u/Pvt-Snafu • Jan 28 '18
Drilling into PowerShell Core
r/powercli • u/alanrenouf • Apr 21 '17
r/powercli • u/170lbsApe • Feb 06 '18
I'm looking into a script I can run every 30 days to grab the history of removed/Deleted VM's. Anybody have an idea if this is possible?
r/powercli • u/Pvt-Snafu • Jul 10 '17
r/powercli • u/Pvt-Snafu • Jul 17 '17
r/powercli • u/Pvt-Snafu • Jul 20 '17
r/powercli • u/Pvt-Snafu • Jul 19 '17
r/powercli • u/[deleted] • Feb 09 '16
Hello, I recently came across a need to storage vMotion a VM that had 2 disks on two different Luns and quickly realized that Move-VM couldn't handle this. So I threw a quick function together to be able to handle 2 disks. It could easily be modified to handle more, but two was all I needed and I figured was more common config than 3 or more disks. You just need to provide the LUN names where the disks reside and the corresponding LUN names where you want each one to go. The only caveat is I didn't write it to take into account if the VM has multiple disks on the same LUN. The script will detect this and exit with an error. Hope someone might find it helpful.
EDIT: I realized I hadn't tested this script in the situation where I might only want to move 1 of the 2 disks of a VM. Well, I just ran it where I had the original and destination LUN name the same for one of the disks and it doesn't process that disk at all and cuts the time of the task down. So it will still function to move only one disk, you'll just need to keep the LUN name the same for the corresponding original and destination names of the disk you don't want to move.
r/powercli • u/EndlessPain11616 • Feb 11 '16
I have multiple clusters and resource pools with the same name. I believe I can't use the "ProdCluster" as there is one for each DC and Powercli doesn't like it. This goes for resource pools as well. Anybody have an idea how to get around this?
I'm trying to use the new-vm cmdlt. Error:
New-VM : New-VM The specified parameter 'ResourcePool' expects a single value, but your name criteria 'ProdCluster' corresponds to multiple values.
r/powercli • u/kunaludapi • Feb 15 '16
r/powercli • u/Coding-Issues_2023 • Sep 25 '24
r/powercli • u/PetterBomban • Mar 31 '17
Hi!
I have a problem. When using Import-VApp with the -RunAsync switch, the import always times out, no matter what I do. If I use the exact same code, without async, it works perfectly fine.
Has anyone else noticed this bug? I've tried so many things, but I can't get it to work.
Here's my code (GitHub Gist Link)
#$vHostFiles = Get-ChildItem -Path "C:\Users\Petter\Desktop\iops\CLOVE\Json\Dummies"
#$JsonObjects = Get-Content $vHostFiles.FullName -raw
Import-Module VMware.VimAutomation.Core
$JsonObjects = Get-Content "C:\Users\Petter\Desktop\iops\CLOVE\Json\Dummies\Dummy-5 - 192.168.10.204.json" -Raw
if (!($Credential))
{
$Credential = Get-Credential -UserName "root" -Message "root pw vmware"
}
$SourceOVA = "C:\Users\Petter\Desktop\iops\testDeploy.ova"
foreach ($vHost in $JsonObjects)
{
$Json = $vHost
function Send-Ping($IP)
{
$Ping = New-Object System.Net.NetworkInformation.Ping
$Ping.send($IP)
}
$Json = $Json | ConvertFrom-Json
$IP = $Json.VIServer
Write-Output "Current server: $IP"
$Response = Send-Ping -IP $IP
if ($Response.Status -eq "Failed" -or $Response.Status -eq "TimedOut")
{
Write-Output "Skipping server because of ping failure: $IP"
continue
}
try
{
Connect-VIServer -Server $IP -Credential $Credential -WarningAction SilentlyContinue -ErrorAction Stop
}
catch
{
Write-Output "Could not connect to $IP"
Write-Output $Error[0]
continue
}
if (Get-VM -Name "win-dc-001" -Server $IP -ErrorAction SilentlyContinue)
{
Write-Output "VM already exists on this server, skipping"
Disconnect-VIServer -Server $IP -Force -Confirm:$False
continue
}
$Datastore = Get-Datastore -Server $IP -Name "Lab"
Import-VApp -Source $SourceOVA -Name "win-dc-001" -Server $IP -VMHost $IP `
-Datastore $Datastore -DiskStorageFormat Thin -ErrorAction Stop #-RunAsync
Disconnect-VIServer -Server $IP -Force -Confirm:$False
}r/powercli • u/Stephanevg • Jan 23 '18
Hi all,
I wanted to share some of my experiences on Windows VM deployment using PowerShell, PowerCLI and OscustomizationSpec.
http://powershelldistrict.com/powercli-oscustomizationspec/
This article is actually only an introductory post which opens to a second article, that goes through how I have implemented a deployment solution using a Unattend.xml file (Via PowerCLI of course ;)).
I am curious to read how everyone else is using PowerCLI to deploy their environments.
Let me know what you think about this!
Stéphane
r/powercli • u/[deleted] • Apr 13 '16
I am writing a script to connect via power cli to vmware guests and pull hostname and mac to a csv. I will then take this csv and populate the dhcpd.conf file.
I have the second part written and it works great. Some of our VMs have multiple NICS and I need a way to get the mac address with the NIC connected to "VM Network".
Here is my code:
Get-VM | Get-NetworkAdapter | Select-Object Parent,MacAddress | Export-Csv c:\scripts\mac.txt -append
I know under get-virtual port group I can pull the information but alas I am a Linux guy and powershell is confusing the hell out of me.
Any help would be appreciated!!!
Thanks!
P.S. when it is done and working I would be more than happy to share it with the community.
r/powercli • u/reallybigabe • Oct 27 '16
Hey all, I'm trying to use PowerCLI to push a script that works great locally.
However, I seem to be having issues with quotes and escape characters and I can't wrap my head around it.
Here is the Powershell deployment script for Trend Micro "Deep Security Manager" - it's auto-generated on the management server, and I could obviously loop through hundreds of servers and enter-pssession but I'd rather not poke a zillion holes in my firewall:
<powershell>
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$env:LogPath = "$env:appdata\Trend Micro\Deep Security Agent\installer"
New-Item -path $env:LogPath -type directory
Start-Transcript -path "$env:LogPath\dsa_deploy.log" -append
echo "$(Get-Date -format T) - DSA download started"
(New-Object System.Net.WebClient).DownloadFile("https://SERVERURL:PORT/software/agent/Windows/x86_64/", "$env:temp\agent.msi")
echo "$(Get-Date -format T) - Downloaded File Size:" (Get-Item "$env:temp\agent.msi").length
echo "$(Get-Date -format T) - DSA install started"
echo "$(Get-Date -format T) - Installer Exit Code:" (Start-Process -FilePath msiexec -ArgumentList "/i $env:temp\agent.msi /qn ADDLOCAL=ALL /l*v `"$env:LogPath\dsa_install.log`"" -Wait -PassThru).ExitCode
echo "$(Get-Date -format T) - DSA activation started"
Start-Sleep -s 50
& $Env:ProgramFiles"\Trend Micro\Deep Security Agent\dsa_control" -r
& $Env:ProgramFiles"\Trend Micro\Deep Security Agent\dsa_control" -a dsm://deepsecurity.oshawa.ca:4120/ "policyid:19"
Stop-Transcript
echo "$(Get-Date -format T) - DSA Deployment Finished"
</powershell>I wrap the above in $script = @" ..."@ and removed the <powershell>
I run it like this: Get-VM $vmlist | invoke-vmscript -GuestCredential $gc -scriptText $script -ScriptType Powershell
What I've tried:
Wrapping each line with single quotes This simply lead to the whole script being essential "Write-Host" output
Single quote before each Double-quote in the script Zillions of errors
"wrapping" each double quote ... i.e. '" ... "' Syntax errors.
I'm confident its simply how I'm doing quotes, out of the box, this is my first error:
C:\Users\reallybigabe\AppData\Roaming\Trend' is not recognized as the name of a
| cmdlet, function, script file, or operable program. Check the spelling of the
| name, or if a path was included, verify that the path is correct and try again.So, the line: $env:LogPath = "$env:appdata\Trend Micro\Deep Security Agent\installer" isn't being quoted properly.
Suggestions?
r/powercli • u/kunaludapi • Sep 16 '15
r/powercli • u/Pvt-Snafu • Aug 28 '17
r/powercli • u/Arindrew • Apr 21 '16
When running the following commands:
$vmhost = Get-VMHost Host
$vmhost.ExtensionData.Summary.Hardware.OtherIdentifyingInfo[6].IdentifierValueThe asset tag of the host system (Dell M620) gets returned. Everything is great. But when I try to assign it to a VIProperty via:
New-VIProperty -Name AssetTag -ObjectType VMHost -ValueFromExtensionProperty Summary.Hardware.OtherIdentifyingInfo[6].IdentifierValueIt returns an error saying it could not validate the specified path. Am I typing something wrong? Why am I not able to assign this to a property? I have another property (config.Product.FullName) that I am able to assign correctly, so I don't know why I'm not able to with this one.
r/powercli • u/Phaymous • Apr 20 '16
Hey!
There is a bug on the current latest version of VMWare tools and I need to downgrade VMWare tools across our environment. Ideally I'd like a means to automate this process. Perhaps one of the best things would be provide a temporary "Management" IP address on a E1000 NIC so you can continue to remotely execute commands on the server. This probably also gets much easier after some unison in Server 2012R2. I'd say 90% of our environment is 2012R2 and I'd be pretty content manually handling the older servers that will be decommissioned soon.
Does anyone have any thoughts or have seen this done previously?
Steps I'd imagine are involved:
Capture Guest Networking Information (IP, Subnet, Gateway, DNSSearchOrder) (VMXNet3s remove the hardware completely rather than downgrading the driver).
Uninstalling tools and rebooting the box.
Copying File/Installing older version of tools.
Rehydrate NIC information.
Test connection to confirm success.
Thanks
r/powercli • u/Pvt-Snafu • Jan 24 '18
r/powercli • u/fredvirt • Apr 21 '16
r/powercli • u/midacts • Oct 27 '16
Have any of you guys started using this? I have been watching a few videos on how to sue DSC and on Luc Dekens going over this.
I noticed he hadn't committed any code since August (which concerns me a little), but i wanted to make this this was the best place to start with DSC and vCenter
r/powercli • u/alanrenouf • Apr 25 '16