Skip to content

Instantly share code, notes, and snippets.

View ankitjoshi8518's full-sized avatar

Ankit Joshi ankitjoshi8518

  • Graphic International Centre
  • Abu Dhabi
View GitHub Profile
@ankitjoshi8518
ankitjoshi8518 / runcommand-powershell-or-shell-script-on-azure-vms.ps1
Last active June 9, 2025 06:47
RunCommand-Powershell-Or-ShellScript-On-Multiple-Azure-VMs
$vms=import-csv (Read-Host "Enter csv file path with vmname,vmrg and subscription columns")
$i=0
$vml=$vms.length
$i=0
$vms | foreach-object -Parallel {
$i++
Write-Host "Working on #" $i
Write-Host "Total items #" $vml
set-azcontext -subscription $vm.subscription
@ankitjoshi8518
ankitjoshi8518 / usefulAzureCLICommands
Last active January 26, 2022 20:37
AzureCli Commands
az group create --location eastus --name rg_Name # creates new resource group
az vm create --resource-group rg_Name --name VMName --generate-ssh-keys --admin-username admuser --image ubuntuLTS --public-ip-sku Standard #Create ubuntu vm . 1cpu, 3.5GB RAM allows ssh to all ip's
az vm delete --resource-group rgname --name vmname
az vm open-port --resource-group rg_Name --name VMName --port 80 # allows any port type from any source to any destination
az vm image list --output table # list possible images available on azure for virtual machines
az vm image list --output table --all
az vm image list --output --offer windowsserver
#when creating a vm, URN can be mentioned which is specific version number for different available images in --images option
@ankitjoshi8518
ankitjoshi8518 / LinuxEssentials
Last active February 7, 2022 16:16
LinuxEssentials
#HANDS ON
#assigning IP address to linux system
ip address # shows the interfaces and IP address assigned to them
cd /etc/netplan # there's a yaml file here. Open it and configure the interface here
# File content after entering required details
network:
ethernets:
eno1:
dhcp4: false
@ankitjoshi8518
ankitjoshi8518 / basicpowershell.ps1
Created January 12, 2022 09:18
Basic Powershell commands
#check interfaces
get-netipinterface
#check ip address on the interface
ipconfig
#Disable dhcp on an interface
Set-NetIPInterface -InterfaceIndex 12 -Dhcp Disabled
#assign static ip to interface
@ankitjoshi8518
ankitjoshi8518 / AD GUID to AAD immutable ID
Created January 7, 2022 10:17
Hard Matching local AD GUID to Azure immutable ID
1. Open a cmd prompt with administrator credentials and run the This command will give us an output file export.txt that has all the user principal names and Immutable IDs of all objects that has UPN.
ldifde -f export.txt -r "(Userprincipalname=*)" -l "objectGuid, userPrincipalName" --- no need to change anything
Once you have the output, run export.txt, it will be exported to a notepad. Copy the Object GUID and proceed to step 3.
Notepad
The output looks like this for each object
----------------------------------------------------
dn: CN=2013 OU=DirSynced OU DC=prakum DC=msftonlinerepro DC=com
@ankitjoshi8518
ankitjoshi8518 / UsefulWindowsCommands
Created December 30, 2021 05:56
Useful windows commands
# Extend windows server evalution license
slmgr /rearm
# know the time until which the evalution edition is valid upto
Slmgr /dli
# Get the current edition
DISM /online /Get-CurrentEdition
# know the target editions to which the OS can be upgraded to
@ankitjoshi8518
ankitjoshi8518 / Azuretablestorage.ps1
Created December 28, 2021 10:35
Working with Azure table storage - Adding and retrieving items
#variables
$storageAccountName = 'storageacc'
$sasToken = 'sastoken'
$dateTime = get-date
# creating new context and define table
$storageCtx = New-AzStorageContext -StorageAccountName $storageAccountName -SasToken $sasToken
$tablename = (Get-AzStorageTable -Name $tableName -Context $storageCtx).Cloudtable
# setting partition key
@ankitjoshi8518
ankitjoshi8518 / Sync internet time on windows client OS.txt
Created December 19, 2021 06:11
Access denied error when trying to set internet time on windows client
#Problem - windows client shows wrong time
#tried to adjust date/time > change date and time > Throws access denied error
#found the below commands to fix this:
net stop w32time
w32tm /unregister
w32tm /register
net start w32time
# Windows time service missing in services so the first command failed
@ankitjoshi8518
ankitjoshi8518 / ExchangeOnline.ps1
Last active December 21, 2021 05:52
Exchange online commands
#Get folder statistics and check if mailbox is full. If in place archive is enabled, mailbox size in exchange admin centre and outlook
#is not correct. This command will show the stats
Get-MailboxFolderStatistics -Identity upn@domain.com -IncludeAnalysis -FolderScope RecoverableItems | Format-Table Name,ItemsInFolder,FolderSize,*Subject*
# grant mailbox access without automapping in outlook
# mailbox id2 is the user who will get access to the mailbox id1
Add-MailboxPermission -Identity <Mailbox ID1> -User <Mailbox ID2> -AccessRights FullAccess -AutoMapping:$false
#Find computers added to domain before 30 days
$limit = (get-date).adddays(-30)
$computers = get-adcomputer -Properties whencreated -Filter {whencreated -lt $limit}