VMware Cloud Community

WinRM and PowerCLI | set-NetworkAdapter hangs

Hi all,

I am currently working on some automation scripts to setup Windows Server on VMWare based on VM-templates.
All the scripts are Powershell-based.


[Invokation-Script (local-server)]   -----WinRM---->   [Remote-Script (remote-server)]   -----PCLI/vAPI----->  vCenter

The Invokation-script uses "invoke-command" with session-option "Credssp" to allow second hops connections.

The PowerCLI modules are loaded on the remote-server.

The scripts executed on the remote-server are located on a network share.

So far so good. 14 out of 15 scripts are working flawlessly.

The problem is caused by one script, or more precise by one command -> Set-NetworkAdapter.

This is the failing script:

$ProgressPreference = ’SilentlyContinue’

Import-Module VMware.VimAutomation.Core

Import-Module VMware.VimAutomation.Vds

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null

Connect-VIServer -Server $vCenterServer

$VM = get-vm -Name $Hostname

$VMNetworkAdapter = ($VM | Get-NetworkAdapter)[0]

Set-NetworkAdapter -NetworkAdapter $VMNetworkAdapter -NetworkName $VcPGName -Confirm:$false  

Disconnect-VIServer -Confirm:$false -Force

If I execute this script with the paramete "-WhatIf" set for the Set-NetworkAdapter command everything works fine.

If I remove the "-WhatIf" switch the VM's network adapter gets reconfigured (Task shows up in vCenter as 'completed') but the script hangs an it does not return from the remote-sessionThe session to the remote host is then locked or busy and i have no chance to get any return value or reconnect to this session.

Other commands like "Set-VM" are working with the exact same type of script.

Is there someone with similar experiences?
Is this a known issue?

I really appreciate your help.

0 Kudos
0 Replies