Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 197835

Re: Percentage display for New VM creation

$
0
0

Try these.

 

Short answer.  Prompt for the creds in the beginning of your script.

$LSCred =  Get-Credential

 

 

Long answer.

 

Local creds

$LID = Read-Host "Enter local admin ID"

$LPwd = Read-Host -assecurestring "Enter local PWD"

$LSPwd = Runtime.InteropServices.Marshal::PtrToStringAuto(

    Runtime.InteropServices.Marshal::SecureStringToBSTR($LPwd))

$LSPword = ConvertTo-SecureString $LSPwd -AsPlainText -Force

$LSCred = New-Object System.Management.Automation.PSCredential $LID, $LSPword

 

If the server is an AD member server add the servername to the $LID.

$LID = Read-Host "Enter local admin ID"

$LPwd = Read-Host -assecurestring "Enter local PWD"

$LSPwd = Runtime.InteropServices.Marshal::PtrToStringAuto(

    Runtime.InteropServices.Marshal::SecureStringToBSTR($LPwd))

$LSPword = ConvertTo-SecureString $LSPwd -AsPlainText –Force

$SLID = $Server + “\” + $LID

$LSCred = New-Object System.Management.Automation.PSCredential $SLID, $LSPword

 

Pass $LSCred to your –Cred

 

Progress bar

$i=0

  $l=($vms).length

    Foreach($vm in $vms) {

        

  1. your script code

       Write-Progress -Activity "Creating VM progress" -Status "Completed % $i of $l" -PercentComplete (100*$i/$l)

       $i++

    }

 

Hope this helps,

JayLB


Viewing all articles
Browse latest Browse all 197835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>