Encrypt All Azure Automation Variables
$ResourceGroupName = '' $AutomationAccountName = '' # Get all variables $variables = Get-AzureRMAutomationVariable -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName # parse through each unencrypted variable Foreach($var in $variables | Where-Object{$_.Encrypted -ne $True}){ # remove the unencrypted variable Remove-AzureRMAutomationVariable -ResourceGroupName $var.ResourceGroupName -AutomationAccountName $var.AutomationAccountName -Name $var.Name # recreate the variable, with the same values and encrypt it New-AzureRMAutomationVariable -ResourceGroupName $var.ResourceGroupName -AutomationAccountName $var.AutomationAccountName -Name $var.Name...
Get All Azure Virtual Machine IP Addresses
[System.Collections.Generic.List[PSObject]] $IPAddresses = @() $VMs = Get-AzureRMVM foreach($VM in $VMs){ foreach($interface in $VM.NetworkProfile.NetworkInterfaces){ $resource = Get-AzureRMResource -id $interface.Id $nic = Get-AzureRmNetworkInterface -Name $resource.Name -ResourceGroupName $resource.ResourceGroupName Get-AzureRmNetworkInterfaceIpConfig -NetworkInterface $nic | Select-Object @{l='VM';e={$VM.Name}}, PrivateIpAddress, PrivateIpAllocationMethod | ForEach-Object{ $IPAddresses.Add($_) } } } $IPAddresses
Find and Load the Azure Automation Hybrid Registration Module
$installPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\System Center Operations Manager\12\Setup\Agent").InstallDirectory $modulePath = Get-ChildItem (Join-Path $installPath "AzureAutomation") -Recurse -Include 'HybridRegistration.psd1' | Select-Object -ExpandProperty FullName Import-Module $modulePath
Quick and Easy Day of the Week Date Picker
$today = [datetime]::Today $dates = @() for($i = $today.AddDays(0).DayOfWeek.value__; $i -ge 0; $i--){ $dates += $today.AddDays(-$i) } $date = $dates | Out-GridView -PassThru
Get All Files with a Certain Extension
# add '-recurse' to include sub folders Get-ChildItem -Path $directory -Filter "*.CSV"
Get All Folders in a Directory
# add '-recurse' to include sub folders Get-ChildItem -Path $directory -Directory
Get All Files in a Directory
# add '-recurse' to include sub folders Get-ChildItem -Path $directory -File
Get All Files and Folders in a Directory
# add '-recurse' to include sub folders Get-ChildItem -Path $directory
Delete Files Older Than Specified Number of Days
# Set number of days, in the past, to delete files $days = 7 # Set directory to create logs in $directory = "C:\Test\Logs" # Get all files in the directory include '-recurse' to also get sub folders $files = Get-ChildItem -Path $directory -File # filter to ones last written to over X number of days $ToDelete = $files |...