Powershell Set Wallpaper

From WikiWiki
Jump to navigation Jump to search

Get all info from azure, and put it as screensaver :-)

function getAllVMOptionsasync()
    #PSComputerName, RunspaceId, PSShowComputerName, DeploymentName, Name, Label, VM, InstanceStatus, IpAddress, InstanceStateDetails, PowerState, InstanceErrorCode, InstanceFaultDomain, InstanceName, InstanceUpgradeDomain, InstanceSize, AvailabilitySetName, DNSName, ServiceName, OperationDescription, OperationId, OperationStatus
		[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

    while((Get-Job -id $id.id).State -ne "completed" )
		if($time -ge 100)
		#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


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) 

foreach($var in $array)
	$string=$var.Name +" - "+ $var.PowerState +" - "+ $var.InstanceSize
	write-host $string - $hight
	$hight += 20
$bmp.Save(".\foo.png" )

Set-WallPaper $wall