piszczynski>Aleks |
piszczynski>Aleks |
||
| Line 20: | Line 20: | ||
Get Policy info | Get Policy info | ||
*Get-AzPolicyDefinition | where {$_.Properties.DisplayName -eq "<policyname>"} | *Get-AzPolicyDefinition | where {$_.Properties.DisplayName -eq "<policyname>"} | ||
Assign to pass to commands | |||
*$definition = Get-AzPolicyDefinition | where {$_.Properties.DisplayName -eq "<policyname>"} | |||
Get Resource group info | Get Resource group info - Best to Create object of group for use in commands | ||
*Get-AzResourceGroup <name of group> | *Get-AzResourceGroup <name of group> | ||
*$rg = Get-AzResourceGroup <Name of group> | |||
Assign Policy | |||
*New-AzPolicyAssignment -Name "NameofPolicy" -DisplayName "Displaynamofpolicy" -scope $rg.ResourceId -PolicyDefinition <AZpolicy definition> | |||
Revision as of 20:59, 22 February 2021
Azure
Set Subsctiption in powershell session: Look at the subscriptions and select the id of the one you want:
- Get-AzSubscription
- $Context = Get-AzSubscription -SubscriptionID <subID>; Set-AzContext $Context
Azure CLI
Identify data locations in shell
- df
Azure powershell
Get Policy info
- Get-AzPolicyDefinition | where {$_.Properties.DisplayName -eq "<policyname>"}
Assign to pass to commands
- $definition = Get-AzPolicyDefinition | where {$_.Properties.DisplayName -eq "<policyname>"}
Get Resource group info - Best to Create object of group for use in commands
- Get-AzResourceGroup <name of group>
- $rg = Get-AzResourceGroup <Name of group>
Assign Policy
- New-AzPolicyAssignment -Name "NameofPolicy" -DisplayName "Displaynamofpolicy" -scope $rg.ResourceId -PolicyDefinition <AZpolicy definition>