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 / Fix-FileAttributes
Last active September 17, 2024 08:47
Remove File Attributes that are not supported in PowerShell
# Removes all OneDrive attributes from files
Get-ChildItem * -Recurse -Depth 999 | % {
$flagsToRemove = 0x00040000 -bor 0x00080000 -bor 0x00100000 -bor 0x00040000 -bor 0x00400000
$flags = [System.IO.File]::GetAttributes($_.FullName)
$fixedFlags = $flags -band (-bnot $flagsToRemove)
[System.IO.File]::SetAttributes($_.FullName, $fixedFlags)
}
function Test-Function {
[CmdletBinding()]
param(
[parameter(Mandatory, Position = 0, ValueFromPipeline)]
[string[]]
$Values
)
process {
$Values.ForEach({