January 8, 2023

Powershell AfterLogin & CheckIpAddressChange

AfterLogin.ps1
#$host.UI.RawUI.ForegroundColor = "Green"
Write-Host "*** After Login Prepartion ***"  -Foregroundcolor Green
$host.UI.RawUI.WindowTitle =  "*** After Login Prepartion ***"
Set-Variable -Name "AzureStorageEmulatorExe" -Value "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe"
Write-Output "*** Start Azure Storage Emulator ***"
& $AzureStorageEmulatorExe start
#Write-Host "*** LoggING into Azure ***"  -Foregroundcolor Green
#& az login --tenant 12345567-8910-47ff-0a65-2765a99ebbce
#Write-Host "*** LoggED into Azure ***"  -Foregroundcolor Green
& $AzureStorageEmulatorExe status
& "C:\Users\...\Documents\BatchFiles\CheckIpAddressChange.ps1"
Pause
CheckIpAddressChange.ps1
$currIpAddress = (Invoke-WebRequest -uri https://ifconfig.me/ip).Content
$prevIpAddress = "155.15.12.31"
$arkpdFirewallAccess = https://.../resource/subscriptions/resourceGroups/networking

#$host.UI.RawUI.ForegroundColor = "Green"
Write-Output "*** Checking for IP Address Change ***"  -Foregroundcolor Green
Write-Output "My current  IP address: $($currIpAddress)"
Write-Output "My previous IP address: $($prevIpAddress)"
$lastDifferentIpAddress = "15.17.107.14"
Write-Output "My last different IP address: $($lastDifferentIpAddress)"
Write-Output "if it changes, re-run ~\Scripts\IpRestrictionTool\allow-my-ip.ps1"
Write-Output "Also navigate to '$($arkpdFirewallAccess)' to update the firewall rule"

Powershell - Find My Ip Address

Clear
$currIpAddress = (Invoke-WebRequest -uri https://ifconfig.me/ip).Content
$prevIpAddress = "155.171.12.2"
Write-Output ""
Write-Output "My current  IP address: $($currIpAddress)"
Write-Output "My previous IP address: $($prevIpAddress)"
Write-Output "if it changes, re-run ~\Scripts\IpRestrictionTool\allow-my-ip.ps1"