forked from jjmolerof/PowerShellScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFix-AzureVault.ps1
More file actions
35 lines (30 loc) · 862 Bytes
/
Copy pathFix-AzureVault.ps1
File metadata and controls
35 lines (30 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[switch]$Report,
[Parameter(Mandatory=$False)]
[switch]$Update,
[Parameter(Mandatory=$False)]
[ValidateNotNull()]
[String]$VMName,
[Parameter(Mandatory=$False)]
[ValidateNotNull()]
[String]$RGName
)
if ($Report) {
$VMs = Get-AzureRmVM
foreach ($VM in $VMs) {
if ($VM.osprofile.secrets.sourcevault.id) {
$Properties = [Ordered]@{
"VMName"=$vm.name;
"RG"=$VM.ResourceGroupName
"KeyVault"=$VM.osprofile.secrets.sourcevault.id
}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj
}}}
if ($Update -and $VMName -and $RGName) {
$VM = Get-AzureRmVM -Name $VMName -ResourceGroupName $RGName
$VM.OSProfile.Secrets = New-Object -TypeName "System.Collections.Generic.List[Microsoft.Azure.Management.Compute.Models.VaultSecretGroup]"
Update-AzureRmVM -VM $VM -ResourceGroupName $RGName
}