Powershell cheat sheet: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Array) |
||
Line 20: | Line 20: | ||
Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx" | Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx" | ||
=Dump Environ= | |||
$environ=(gci env:*).GetEnumerator() | Sort-Object Name | Out-String | |||
write-output $environ | |||
=Array= | =Array= |
Revision as of 09:20, 19 April 2021
Execution Policy
get-ExecutionPolicy set-ExecutionPolicy RemoteSigned set-ExecutionPolicy unrestricted
Install AZ Module
Install-Module -Name AZ -AllowClobber -Scope CurrentUser Import-Module Az -Verbose
Connect AZ
Connect-AzAccount Connect-AzAccount -device connect-azaccount -UseDeviceAuthentication
- List Subscriptions
Get-AzSubscription Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx"
Dump Environ
$environ=(gci env:*).GetEnumerator() | Sort-Object Name | Out-String write-output $environ
Array
$allscopes = @() $cnt++ $allscopes += ,($cnt,"Val1-1","Val1-2","Val1-3") $cnt++ $allscopes += ,($cnt,"Val2-1","Val2-2","Val2-3") $cnt++ $allscopes += ,($cnt,"Val3-1","Val3-3","Val3-3")
foreach ($row in @($allscopes)) { write-output "->$($row[0]) <--> $($row[1]) <--> $($row[2]) <--> $($row[3]) <-" }
#Modify cell for ( $index = 0; $index -lt $allscopes.count; $index++ ) { $allscopes[$index][0] = "X" }
write-output "------------" foreach ($row in @($allscopes)) { write-output "->$($row[0]) <--> $($row[1]) <--> $($row[2]) <--> $($row[3]) <-" }