Skip to content

Instantly share code, notes, and snippets.

View StasDevOps2bcloud's full-sized avatar

Stanislav Dubrovskiy StasDevOps2bcloud

View GitHub Profile
Get-AzSubscription | Foreach-Object {
$sub = Set-AzContext -SubscriptionId $_.SubscriptionId
$vnets = Get-AzVirtualNetwork
foreach ($vnet in $vnets) {
[PSCustomObject]@{
Subscription = $sub.Subscription.Name
Name = $vnet.Name
Vnet = $vnet.AddressSpace.AddressPrefixes -join ', '
Subnets = $vnet.Subnets.AddressPrefix -join ', '
Param(
[Parameter(Mandatory=$false)]
[ValidateNotNullOrEmpty()]
[string]$NewToken
)
Set-ExecutionPolicy Bypass -Scope Process -Force
Connect-AzAccount
#Clear Screen
cls
#Present a welcome screen
Write-Host "2bcloud RI AAD Groups Assigner v1.0" -BackgroundColor Gray -ForegroundColor Red
Write-Host "This script will do the following:" -BackgroundColor DarkGray
Write-Host "1. Check if RI_Readers and RI_Owners groups exist in AAD and if not create them." -ForegroundColor Blue
Write-Host "2. Assign RI_Readers group to each reservation with Reservations Reader role." -ForegroundColor Blue
Write-Host "3. Assign RI_Readers group to each reservation with Owner role." -ForegroundColor Blue
Pause
#Only required when running locally from your computer
Set-ExecutionPolicy Bypass -Scope Process -Force
#Install and import PSSendGrid PowerShell module:
if (Get-Module -ListAvailable -Name PSSendGrid) {
Write-Warning "PSSendGrid Module is installed"
}
else {
Write-Warning "PSSendGrid Module is not installed"
Write-Host "Installing PSSendGrid PowerShell Module.."
#STOP
$ShortcutPath = [System.IO.Path]::Combine($env:USERPROFILE, "Desktop", "Dalia-Stop-Hilan-VM.lnk")
$TargetPath = "powershell.exe"
$Arguments = "-NoExit -Command &{cls;Invoke-WebRequest -Method Post -Uri https://9f6a8358-7011-4c25-b760-33eb94f7f8ab.webhook.we.azure-automation.net/webhooks?token=<Azure Runbook WebHook Token>}"
$IconPath = "C:\Windows\UUS\amd64\WindowsUpdateImportant.ico"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutPath)
$Shortcut.IconLocation = $IconPath
$Shortcut.TargetPath = $TargetPath
$Shortcut.Arguments = $Arguments