Skip to content

Instantly share code, notes, and snippets.

View danielniccoli's full-sized avatar
🐢
is how I roll.

Daniel Niccoli danielniccoli

🐢
is how I roll.
View GitHub Profile
# This script adds the permissions required for Azure Automation Jobs running on a Hybrid Worker under custom credentials
# Ref: https://learn.microsoft.com/en-us/azure/automation/migrate-existing-agent-based-hybrid-worker-to-extension-based-workers?tabs=bicep-template%2Cwin-hrw#permissions-for-hybrid-worker-credentials
$identity = "..." # Set the identity used in the custom credential here
# Do not change anything after this line
$folder = "C:\Packages\Plugins\Microsoft.Azure.Automation.HybridWorker.HybridWorkerForWindows"
$fileSystemRights = [System.Security.AccessControl.FileSystemRights]::ReadAndExecute
$inheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
@danielniccoli
danielniccoli / gist:f221abdd7567b7cc01cc91e9ff926270
Created October 12, 2023 15:50
Remove File Attributes that are not supported in PowerShell
Get-Item * | % {
$flagsToRemove = 0x00040000 -bor 0x00080000 -bor 0x00100000 -bor 0x00040000 -bor 0x00400000
$flags = ($_ | Get-ItemProperty).Attributes
$fixedFlags = $flags -band (-bnot $flagsToRemove)
$_ | Set-ItemProperty -Name attributes -Value $fixedFlags
}
function Test-Function {
[CmdletBinding()]
param(
[parameter(Mandatory, Position = 0, ValueFromPipeline)]
[string[]]
$Values
)
process {
$Values.ForEach({