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 / dockerfile
Last active July 30, 2020 21:53
PowerShell Universal dockerfile
FROM mcr.microsoft.com/powershell:lts-ubuntu-18.04
LABEL description="Universal - The ultimate platform for building web-based IT Tools"
EXPOSE 5000
COPY [ "./stage", "/home/" ]
ENTRYPOINT ["./home/Universal/Universal.Server"]
@adamdriscoll
adamdriscoll / sendSocket.ps1
Last active June 1, 2020 18:35
Send a command over a socket
function Send-Socket {
param(
$IPAddress,
$Port,
$Command
)
$ipEndpoint = [System.Net.IPEndPoint]::new([System.Net.IPAddress]$IPAddress, $Port)
$socket = [System.Net.Sockets.Socket]::new($ipEndpoint.AddressFamily, 'Stream', 'TCP')
$socket.Connect($ipEndpoint)
Import-Module .\module.psm1
function New-ComponentPage {
param(
$Page
)
New-Page
}
@adamdriscoll
adamdriscoll / UDv3NavDemo.ps1
Last active April 1, 2020 22:46
Universal Dashboard v3 Nav Demo
function New-AppBar {
$Drawer = New-UDDrawer -Children {
New-UDList -Children {
New-UDListItem -Label "Page1" -OnClick { Invoke-UDRedirect -Url "/page1" }
New-UDListItem -Label "Page2" -OnClick { Invoke-UDRedirect -Url "/page2" }
New-UDListItem -Label "Page3" -OnClick { Invoke-UDRedirect -Url "/page3" }
}
}
@adamdriscoll
adamdriscoll / New-Detour.ps1
Created July 28, 2016 17:45
Example of how to use EasyHook with powershell to override GetSystemTimeAsFileTime
function New-Detour
{
param(
$Library,
$FunctionName,
[ScriptBlock]$Detour,
[String[]]$ReferencedAssemblies
)
#Download from easyhook.codeplex.com
@adamdriscoll
adamdriscoll / influxdb.ps1
Created December 6, 2018 03:33
Example of InfluxDB integration into Universal Dashboard
Import-Module UniversalDashboard
Get-UDDashboard | Stop-UDDashboard
$EI = New-UDEndpointInitialization -Module (Join-Path $PSScriptRoot 'influxdb.psm1')
$Cache:NetworkStats = @(
'\network adapter(*)\bytes received/sec'
'\network adapter(*)\bytes sent/sec'
)
@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