This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$xml = gc C:\appassoc.xml | |
$enc = [System.Text.Encoding]::Unicode.GetBytes($xml) | |
$encXML = [Convert]::ToBase64String($enc) | |
$encXML |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$action1 = { | |
$psise.CurrentFile.Editor.InsertText("# --[ ]") | |
# Get the current cursor position | |
$currentLine = $psISE.CurrentFile.Editor.CaretLine | |
$currentColumn = $psISE.CurrentFile.Editor.CaretColumn | |
# Calculate the new column position | |
$newColumn = [math]::Max(1, $currentColumn - 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$TenantID = "<tenantID>" | |
$ManagedIdentity = "<MSI name>" | |
$Permissions = @("DeviceManagementManagedDevices.Read.All", "DeviceManagementManagedDevices.ReadWrite.All", "AuditLog.Read.All", "User.Read.All") | |
$GraphAppId = "00000003-0000-0000-c000-000000000000" | |
Connect-AzureAD -TenantId $TenantID | |
$ManagedIdentityServicePrincipal = (Get-AzureADServicePrincipal -Filter "displayName eq '$ManagedIdentity'") | |
$GraphServicePrincipal = Get-AzureADServicePrincipal -Filter "appId eq '$GraphAppId'" | |
foreach ($Permission in $Permissions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Add New Snippet ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
$text = @" | |
<paste your PS code here> | |
"@ | |
New-IseSnippet -Title "<name of snippet>" -Description "<description of snippet>" -Author "mattGPT" -Text $text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Invoke Azure Runbook Webhook ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
# --[ Set Variables ] | |
$webhookURI = "https:\\<webhook-URI>" | |
# --[ Parameters for Webhook ] | |
$params = @{ | |
param1 = "deviceName" | |
param2 = "userName" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Log Function ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
# --[ Set vars ] | |
$customer = "mattGPT" | |
$feature = "Stuff" | |
$logPath = "C:\ProgramData\$customer\$feature" | |
$logfile = "$logPath\$feature.log" | |
if(!(Test-Path $logPath)){ New-Item -Path $logPath -ItemType Directory -Force } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Windows Toast Message ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
function Toast($Title,$msgText){ | |
# Main script | |
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null | |
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null | |
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Decode base64 to file ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
$b64 = "paste here all the base64 text" | |
$filename = "path\to\imagefile" | |
$bytes = [Convert]::FromBase64String($b64) | |
[IO.File]::WriteAllBytes($filename, $bytes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Encode image to base64 ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
$path = "path\to\image\file.jpg" | |
[convert]::ToBase64String((Get-Content $path -Encoding byte)) >> "path\to\save\base64\text\to.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --[ Encode URI to base64 ] | |
# --[ Matt Balzan | mattGPT.co.uk ] | |
$url = '<your_URI>' | |
$enc = [System.Text.Encoding]::Unicode.GetBytes($url) | |
$encURL = [Convert]::ToBase64String($enc) | |
$encURL |