Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 5932
โ†ง

Using PowerShell Direct for Script Locking

$
0
0

Here is one of the most helpful code snippets that I have come up with using PowerShell Direct:

function waitForPSDirect([string]$VMName, $cred){
ย  ย Write-Output "[$($VMName)]:: Waiting for PowerShell Direct (using $($cred.username))"
ย  ย while ((icm -VMName $VMName -Credential $cred {"Test"} -ea SilentlyContinue) -ne "Test") {Sleep -Seconds 1}}

In essence this function allows you to block your script until the requested virtual machine has booted and is responding to PowerShell Direct. ย This is immensely useful when you are provisioning virtual machine and need to know when the guest operating system is actually up and running - and has become a staple function in many of my scripts.

Cheers,
Benย 

โ†ง

Viewing all articles
Browse latest Browse all 5932

Latest Images

Trending Articles



Latest Images