Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .NOTES
- #------------------------------------------------------------------------------------------
- # Date : 12-07-2017
- # Script name : Set-AzureRMLock.ps1
- # Description : Set locks on resources for accidental deletion
- # Created by : Ralph Jansen
- # Extra module :
- # Copyright : ©2017 Ralph Jansen, all rights reserved.
- # History : RJA 12-07-2017 Initial version
- #
- #------------------------------------------------------------------------------------------
- .DESCRIPTION
- Set locks on resources for accidental deletion
- #>
- Start-Transcript -Path '$env:TMP\Set-AzureRMLock.log' -Force
- Write-Verbose -Verbose "Script started..."
- Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"
- Login-AzureRmAccount -SubscriptionName "<Subscription Name>"
- # Removing resource locks
- Get-AzureRmResourceLock | Remove-AzureRmResourceLock -Force
- # Setting resource locks
- $Resource = Find-AzureRmResource
- foreach ($item in (Find-AzureRmResource))
- {
- Set-AzureRmResourceLock -resourcename $item.ResourceName -ResourceType $item.ResourceType -resourcegroup $item.ResourceGroupName -LockName "Lock" -LockLevel CanNotDelete -LockNotes "Locked for accidental deletion" -Force
- }
- Stop-Transcript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement