Skip to content

Instantly share code, notes, and snippets.

View irlperu's full-sized avatar
🏠
Working from home

Aidan Keane irlperu

🏠
Working from home
View GitHub Profile
@irlperu
irlperu / DisableAADSync.ps1
Last active August 9, 2019 15:07
Turn off AD Connect and leave users as Cloud Only
# https://support.microsoft.com/en-us/help/2619062/you-can-t-manage-or-remove-objects-that-were-synchronized-through-the
# Connect to AAD
Connect-MsolService
# Disable AAD Connect Sync atAAD Level -- This will set users to be Cloud Only
Set-MsolDirSyncEnabled -EnabledDirSync $false
# To Check the Status of the previous command, run the following command
(Set-MsolDirSyncEnabled).DirectorySynchronizationEnabled
@irlperu
irlperu / publicip.ps1
Created May 16, 2019 20:23
Get All Public IP's in Azure Subscription
#Login-AzAccount
Get-AzSubscription
Select-AzSubscription -SubscriptionId SubscriptionIdHere
Get-AzPublicIpAddress | select -Property *name,@{name='sku';e={$_.sku.name}}
# Loop through all Subscriptions that you have access to and export the information
Get-AzSubscription | foreach-object {
@irlperu
irlperu / exportchrome.ps1
Created May 10, 2019 14:06
Export Chrome Bookmarks
#credits: Mostly to tobibeer and Snak3d0c @ https://stackoverflow.com/questions/47345612/export-chrome-bookmarks-to-csv-file-using-powershell
#Path to chrome bookmarks
$pathToJsonFile = "$env:localappdata\Google\Chrome\User Data\Default\Bookmarks"
$htmlOut = 'C:\temp\ChromeBookmarks.html'
$htmlHeader = @'
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!--This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
@irlperu
irlperu / vmextensions.ps1
Created May 3, 2019 01:22
Get VM Extensions
# Discover VM extensions available in a Region - change out EastUS2 to the region you need
# Windows VM's
# https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/features-windows#run-vm-extensions
Get-AzVmImagePublisher -Location "EastUS2" | Get-AzVMExtensionImageType | Get-AzVMExtensionImage | Select Type, Version
# Linux VM's
# https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/features-linux
@irlperu
irlperu / azgraph.ps1
Created April 30, 2019 14:05
Search Azure at Scale
# Querying Azure at scale --
# Make sure to install this module - there is currently only one command available inside this module - 'search'
# The advantage of using this module is that is will query across subscriptions without needing to define them
#Install-Module -Name Az.ResourceGraph
#Get-Command -Module Az.ResourceGraph
#Login-AzAccount -UseDeviceAuthentication
@irlperu
irlperu / pimaccess.ps1
Created March 22, 2019 20:46
Privileged Access Management for a time period
// Great feature to provide temporary access using PIM
// https://scriptautomaterepeat.com/privileged-access-management/?fbclid=IwAR1iub0C2L6Jt0oYpADDotjoKLwXHwQWQGoMxcaOYOA6Nqsu0dxdqGgdKp8
// Example 1
$Time = New-TimeSpan -Minutes 15
Add-ADGroupMember -Identity "TESTGroup1" -Members "tstuser" -MemberTimeToLive $Time
//Example 2
@irlperu
irlperu / ServerStatus.ps1
Last active June 5, 2019 18:51
Get Server Status (Running / Deallocated) in a Resource Group for
Login-AzAccount -UseDeviceAuthentication
Get-AzContext
$VMs = @()
$RGs = Get-AzResourceGroup
foreach($RG in $RGs)
{
$VMs += Get-AzVM -ResourceGroupName $RG.ResourceGroupName -Status
}
# Take out the # at the end of the next line if you want to output to csv