Windows PowerShell Profiles
Applies To: Windows PowerShell 2.0 When you add aliases, functions, and variables, you are actually adding them only to the current Windows PowerShell session. If you exit the session...
Read MoreApplies To: Windows PowerShell 2.0 When you add aliases, functions, and variables, you are actually adding them only to the current Windows PowerShell session. If you exit the session...
Read MoreFirst you have to create a CSV file with the following entry’s: VMName,Note VM1,Domain Controller VM2,Database Server The second step is to run this one-liner. The one-liner will add...
Read MoreBelow function should be include in the script: function Send-SMTPmail($to, $from, $subject, $smtpserver, $body, $attachment) {$mailer = new-object Net.Mail.SMTPclient($smtpserver)$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)$msg.IsBodyHTML = $true$attachment = new-object Net.Mail.Attachment($attachment)$msg.attachments.add($attachment)$mailer.send($msg)} Command which...
Read MoreFor Loop: for ($i=1; $i -le 5; $i++){Write-Host $i} Output:12345——————————$i=1for (; $i -le 5; $i++){Write-Host $i}——————————$ints = @( 1, 2, 3, 4, 5) for ($i=0; $i -le $ints.Length –...
Read MoreThere are two ways of doing this really: 1. Add a line to a start of each of your scripts to make sure it loads the PowerCLI snapin, without...
Read MoreCommand:(get-vmhost).count Output will be like this: 51 (or) Command : get-vmhost | measure-object Output will be:Count : 51Average :Sum :Maximum :Minimum :Property :
Read MoreIf you want to connect to more than one virtual center at the same time, here the starting code : $vcs = @()$vcs += connect-viserver “vc 1”$vcs += connect-viserver...
Read MoreGet-VM | Select Name, @{N=”Cluster”;E={Get-Cluster -VM $_}},@{N=”ESX Host”;E={Get-VMHost -VM $_}},@{N=”Datastore”;E={Get-Datastore -VM $_}} |Export-Csv -NoTypeInformation C:ScriptsVM_CLuster_Host_Datastore.csv
Read Moreparam( [string] $VIServer ) if ($VIServer -eq “”){Write-HostWrite-Host “Please specify a VI Server name eg….”Write-Host ” powershell.exe Report.ps1 MYVISERVER”Write-HostWrite-Hostexit} function PreReq{if ((Test-Path REGISTRY::HKEY_CLASSES_ROOTWord.Application) -eq $False){Write-Host “This script directly outputs...
Read More