Powershell Set Wallpaper: Difference between revisions
(Created page with " <syntaxhighlight lang="powershell"> function getAllVMOptionsasync() { #PSComputerName, RunspaceId, PSShowComputerName, DeploymentName, Name, Label, VM, InstanceStatus, I...") (change visibility) |
No edit summary (change visibility) |
||
Line 1: | Line 1: | ||
Get all info from azure, and put it as screensaver :-) | |||
<syntaxhighlight lang="powershell"> | <syntaxhighlight lang="powershell"> |
Revision as of 11:58, 13 March 2014
Get all info from azure, and put it as screensaver :-)
<syntaxhighlight lang="powershell"> function getAllVMOptionsasync() {
#PSComputerName, RunspaceId, PSShowComputerName, DeploymentName, Name, Label, VM, InstanceStatus, IpAddress, InstanceStateDetails, PowerState, InstanceErrorCode, InstanceFaultDomain, InstanceName, InstanceUpgradeDomain, InstanceSize, AvailabilitySetName, DNSName, ServiceName, OperationDescription, OperationId, OperationStatus
#$running=$false
#$templist=@() $templist=$null $scriptblock={ param($subscriptionName,$proxycreds)
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $proxycreds
#select-azuresubscription -SubscriptionName $subscriptionName (Get-AzureService).servicename | foreach {Get-AzureVM -ServiceName $_ } } $id = Start-Job –Name getAllVMOptions –Scriptblock $scriptblock -ArgumentList @($subscriptionName, $global:proxycreds) | select id
$time=0
while((Get-Job -id $id.id).State -ne "completed" ) { $time++
if($time -ge 100) {$time=0} #write-host "running" Write-Progress -activity "Waiting..." -status "Time: $time" -PercentComplete ($time)
Start-Sleep 1 } $templist = Receive-Job -Id $id.id $finallist = $templist # $list | ft
#Get-Job -id $id.id Remove-Job -id $id.id
return $finallist
}
Function Set-WallPaper($Value) { write-host "setting wall to $Value" Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "WallpaperStyle" -Value 6 Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
$array=getAllVMOptionsasync
Add-Type -AssemblyName System.Drawing $bmp = new-object System.Drawing.Bitmap 800,600 $font = new-object System.Drawing.Font Consolas,12 $brushBg = [System.Drawing.Brushes]::LightSkyBlue $brushFg = [System.Drawing.Brushes]::Black $graphics = [System.Drawing.Graphics]::FromImage($bmp) $graphics.FillRectangle($brushBg,0,0,$bmp.Width,$bmp.Height)
$hight=10 foreach($var in $array) { $string=$var.Name +" - "+ $var.PowerState +" - "+ $var.InstanceSize write-host $string - $hight $graphics.DrawString($string,$font,$brushFg,300,$hight) $hight += 20 } $graphics.Dispose() $bmp.Save(".\foo.png" )
$wall="$home\foo.png" Set-WallPaper $wall </syntaxhighlight">