Skip to content

Instantly share code, notes, and snippets.

View adamdriscoll's full-sized avatar
:bowtie:

Adam Driscoll adamdriscoll

:bowtie:
View GitHub Profile
@adamdriscoll
adamdriscoll / LoginPageForUA.ps1
Last active February 7, 2020 15:53
Creating a login page for Universal Automation
$AuthMethod = New-UDAuthenticationMethod -Endpoint {
param([pscredential]$Credential)
New-UDAuthenticationResult -Success -UserName $Credential.UserName
}
$AuthPolicy = New-UDAuthorizationPolicy -Name "Policy" -Endpoint {
param($ClaimsPrincipal)
$UserName = $ClaimsPrincipal.Identity.Name
$Session:UserRole = ""
@adamdriscoll
adamdriscoll / AppToken.ps1
Created January 31, 2020 17:55
Using a Reader AppToken in Universal Automation
[DBG]: PS C:\Users\adamr>> Get-UAScript -AppToken $AppToken.Token
Id : 1
Name : Script.ps1
Description :
CreatedTime : 1/31/2020 10:51:40 AM
ManualTime : 0
CommitId : c45063d8f9f68805ffdf68231015aaaec47b13d6
Content : Write-Host "Hello"
@adamdriscoll
adamdriscoll / UARoles.ps1
Created January 31, 2020 17:54
Creating Identities and Assigning Roles in Universal Automation
[DBG]: PS C:\Users\adamr>> $Role = Get-UARole -Name Reader
[DBG]: PS C:\Users\adamr>> $Role
Id Name Description
-- ---- -----------
3 Reader Readers have read-only access to UA. They cannot make changes to any entity within the system.
[DBG]: PS C:\Users\adamr>> $Identity = New-UAIdentity -Name Jeff -Role $Role
[DBG]: PS C:\Users\adamr>> $AppToken = Grant-UAAppToken -Identity $Identity
@adamdriscoll
adamdriscoll / FullScript.ps1
Created January 29, 2020 16:36
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
@adamdriscoll
adamdriscoll / ScheduleScript.ps1
Created January 29, 2020 16:04
Schedule a script to run as another user
$Script = Get-UAScript -Name 'whoami.ps1'
New-UASchedule -Script $Script -Credential $Credential -Cron '*/2 * * * *'
@adamdriscoll
adamdriscoll / InvokeScript.ps1
Created January 29, 2020 16:02
Invoking a script in Universal Automation with a credential
$Script = Get-UAScript -Name 'whoami.ps1'
Invoke-UAScript -Script $Script -Credential $Credential
@adamdriscoll
adamdriscoll / NewCredential.ps1
Last active January 29, 2020 16:33
Creates a new credential for Universal Automation
$PasswordVariable = Get-UAVariable -Name 'password'
$Credential = New-UACredential -UserName 'iis' -Password $PasswordVariable
@adamdriscoll
adamdriscoll / SetSecretInUa.ps1
Last active January 29, 2020 16:10
Sets a secret variable in Universal Automation
$SecretManager = Get-UASecretManager -Name 'PSSecretStore'
Set-UAVariable -Name 'password' -Value 'P@$$w0rd' -SecretManager $SecretManager
@adamdriscoll
adamdriscoll / NewSecretManager.ps1
Last active January 29, 2020 16:15
Creates a new secret manager in Universal Automation
New-UASecretManager -Name 'PSSecretStore' -Get {
param($Name)
Get-SSSecret -Name $Name -KeyPath C:\keyfile.bin -StorePath C:\store.bin
} -Set {
param($Name, $Value)
Set-SSSecret -Name $Name -Value $Value -KeyPath C:\keyfile.bin -StorePath C:\store.bin
}
@adamdriscoll
adamdriscoll / GetSecret.ps1
Created January 29, 2020 15:52
Gets a secret from a PSSecretStore
Get-SSSecret -Name 'password' -KeyPath C:\keyfile.bin -StorePath C:\store.bin