Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created January 29, 2020 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamdriscoll/210d34ffaae0cc74d38d079d9df7a8ec to your computer and use it in GitHub Desktop.
Save adamdriscoll/210d34ffaae0cc74d38d079d9df7a8ec to your computer and use it in GitHub Desktop.
Full example for this post
Import-Module UniversalAutomation
Import-Module UniversalAuotmation.Dashboard
Import-Module PSSecretStore
$ComputerName = "http://localhost:10000"
Start-UAServer -Port 10000
$Cache:ComputerName = $ComputerName
Connect-UAServer -ComputerName $ComputerName
$Dashboard = New-UADashboard
$Script = New-UAScript -Name 'Whoami' -ScriptBlock {
whoami
}
Export-SSKey -KeyPath F:\keyfile.bin
Set-SSSecret -Name 'password' -Value 'P@$$w0rd' -KeyPath F:\keyfile.bin -StorePath F:\store.bin
$SecretManager = New-UASecretManager -Name 'PSSecretStore' -Get {
param($Name)
Get-SSSecret -Name $Name -KeyPath F:\keyfile.bin -StorePath F:\store.bin
} -Set {
param($Name, $Value)
Set-SSSecret -Name $Name -Value $Value -KeyPath F:\keyfile.bin -StorePath F:\store.bin
}
New-UAVariable -Name 'password' -Value 'P@$$w0rd' -SecretManager $SecretManager | Out-Null
$PasswordVariable = Get-UAVariable -Name 'password'
$Credential = New-UACredential -UserName 'iis' -Password $PasswordVariable
Invoke-UAScript -Script $Script -Credential $Credential
New-UASchedule -Script $Script -Cron '*/2 * * * *' -Credential $Credential | Out-Null
Start-UDDashboard -Dashboard $Dashboard -Port 10001 -AdminMode
Start-Process http://localhost:10001
Wait-Debugger
Stop-UAServer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment