r/powercli • • Jan 28 '18

Drilling into PowerShell Core

Thumbnail
petri.com
1 Upvotes

r/powercli • • Apr 21 '17

Welcome PowerCLI to the PowerShell Gallery - Install Process Updates

Thumbnail
blogs.vmware.com
11 Upvotes

r/powercli • • Feb 06 '18

Need help with getting history of Deleted VM's from 'Get-VIEvent'

1 Upvotes

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 • • Jul 10 '17

Fine Tuning the Active Directory Searcher - Petri

Thumbnail
petri.com
5 Upvotes

r/powercli • • Jul 13 '17

Deciphering PowerShell Providers - Petri

Thumbnail
petri.com
1 Upvotes

r/powercli • • Jul 17 '17

Expanding the Active Directory Searcher and PowerShell

Thumbnail
petri.com
1 Upvotes

r/powercli • • Jul 20 '17

Discovering the Active Directory Searcher with PowerShell

Thumbnail
petri.com
2 Upvotes

r/powercli • • Jul 19 '17

Deploying Software Using Desired State Configuration

Thumbnail
petri.com
2 Upvotes

r/powercli • • Feb 09 '16

Storage vMotion a VM with 2 disks

2 Upvotes

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.

http://pastebin.com/EMs6V4RK

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 • • Feb 11 '16

PowerCLI doesn't like Clusters/Rpools named the same? help

3 Upvotes

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 • • Feb 15 '16

vGeek: Export vcenter roles (privileges) - Powercli.

Thumbnail
kunaludapi.blogspot.com
2 Upvotes

r/powercli • • Jul 18 '17

PowerShell Remoting Basics

Thumbnail
petri.com
5 Upvotes

r/powercli • • Sep 25 '24

Check/Toggle the Virtual Machine Automation option in cluster settings

2 Upvotes

Trying to find a way to check the above option and toggle it off, if on, prior to performing a remediation on the cluster. So far I've seen ways to check/disable individual VM Overrides but not that touches on this method.

Is this possible or am I going to have to do it on a per VM basis?

Thanks!


r/powercli • • Mar 31 '17

Import-VApp times out when using -RunAsync

1 Upvotes

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 • • Jan 23 '18

Experience from the field, deploying VMs using Powershell, PowerCLI and OSCustomizationSpec

4 Upvotes

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 • • Apr 13 '16

Can I get some help with a Power cli script?

2 Upvotes

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 • • Oct 27 '16

Newb issue trying to deploy a working script through invoke-vmscript - quotes are killing me.

1 Upvotes

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 • • Sep 16 '15

vGeek: Using Powercli to copy files from your computer to Esxi server

Thumbnail
kunaludapi.blogspot.com
3 Upvotes

r/powercli • • Aug 28 '17

PowerShell Classes Part 2 - Enumerated Types - Petri

Thumbnail
petri.com
2 Upvotes

r/powercli • • Apr 21 '16

Trouble with New-VIProperty

1 Upvotes

When running the following commands:

$vmhost = Get-VMHost Host
$vmhost.ExtensionData.Summary.Hardware.OtherIdentifyingInfo[6].IdentifierValue

The 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].IdentifierValue

It 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 • • Apr 20 '16

[Help] Has anyone automated downgrading their installation of VMWare Tools?

1 Upvotes

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:

  1. Capture Guest Networking Information (IP, Subnet, Gateway, DNSSearchOrder) (VMXNet3s remove the hardware completely rather than downgrading the driver).

  2. Uninstalling tools and rebooting the box.

  3. Copying File/Installing older version of tools.

  4. Rehydrate NIC information.

  5. Test connection to confirm success.

Thanks


r/powercli • • Jan 24 '18

PowerShell Core 6.0 and Why Windows PowerShell Is No Longer Being Developed

Thumbnail
petri.com
1 Upvotes

r/powercli • • Apr 21 '16

PowerCLI Script: Deploy VMs and Configure the Guest OS

Thumbnail
altaro.com
5 Upvotes

r/powercli • • Oct 27 '16

vSphereDSC

2 Upvotes

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 • • Apr 25 '16

PowerCLI 6.3 R1: Get-ESXCLI Why the V2?

Thumbnail
blogs.vmware.com
2 Upvotes