# read in the certificate from a pre-existing PFX file $cert = Get-PfxCertificate-FilePath"$env:temp\codeSignCert.pfx"
# find all scripts in your user profile... Get-ChildItem-Path$home\Documents -Filter *.ps1 -Include *.ps1 -Recurse-ErrorAction SilentlyContinue | # ...that do not have a signature yet... Where-Object { ($_ | Get-AuthenticodeSignature).Status -eq'NotSigned' } | # and apply one # (note that we added -WhatIf so no signing occurs. Remove this only if you # really want to add digital signatures!) Set-AuthenticodeSignature-Certificate$cert-TimestampServer http://timestamp.digicert.com -WhatIf
# read in the certificate from a pre-existing PFX file $cert = Get-PfxCertificate-FilePath"$env:temp\codeSignCert.pfx"
# find all scripts in your user profile... Get-ChildItem-Path$home-Filter *.ps1 -Include *.ps1 -Recurse-ErrorAction SilentlyContinue | # ...that do not have a signature yet... Where-Object { ($_ | Get-AuthenticodeSignature).Status -eq'NotSigned' } | # and apply one # (note that we added -WhatIf so no signing occurs. Remove this only if you # really want to add digital signatures!) Set-AuthenticodeSignature-Certificate$cert-WhatIf
# find all scripts in your user profile... Get-ChildItem-Path$home-Filter *.ps1 -Include *.ps1 -Recurse-ErrorAction SilentlyContinue | # ...and check signature status Get-AuthenticodeSignature
# get data in parallel via PowerShell remoting # make sure you adjust the computer names $computer1 = 'server1' $computer2 = 'server2' $data = Invoke-Command { Get-Process } -ComputerName$computer1, $computer2
# separate the data per computer $infos = $data | Group-Object-Property PSComputerName -AsHashTable-AsString
# we use private variables only. No need for global scope $balloon = New-Object System.Windows.Forms.NotifyIcon $cleanup = { # this gets executed when the user clicks the balloon tip dialog
# take the balloon from the event arguments, and dispose it $event.Sender.Dispose() # take the event handler names also from the event arguments, # and clean up Unregister-Event-SourceIdentifier$event.SourceIdentifier Remove-Job-Name$event.SourceIdentifier $name2 = "M" + $event.SourceIdentifier Unregister-Event-SourceIdentifier$name2 Remove-Job-Name$name2 } $showBalloon = { # this gets executed when the user clicks the tray icon $event.Sender.ShowBalloonTip(5000) }
# use unique names for event handlers so you can open multiple balloon tips $name = [Guid]::NewGuid().Guid
# subscribe to the balloon events $null = Register-ObjectEvent-InputObject$balloon-EventName BalloonTipClicked -Source$name-Action$cleanup $null = Register-ObjectEvent-InputObject$balloon-EventName MouseClick -Source"M$name"-Action$showBalloon
# use the current application icon as tray icon $path = (Get-Process-id$pid).Path $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
# configure the balloon tip $balloon.BalloonTipIcon = $Icon $balloon.BalloonTipText = $Text $balloon.BalloonTipTitle = $Title
# make the tray icon visible $balloon.Visible = $true # show the balloon tip $balloon.ShowBalloonTip(5000) }