https://github.com/PowerShellCrack/MyAzureProfileScript
Profile script for your system to simply manage VMs in Azure
https://github.com/PowerShellCrack/MyAzureProfileScript
Last synced: 4 months ago
JSON representation
Profile script for your system to simply manage VMs in Azure
- Host: GitHub
- URL: https://github.com/PowerShellCrack/MyAzureProfileScript
- Owner: PowerShellCrack
- Created: 2020-12-15T14:34:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-11T00:32:26.000Z (over 3 years ago)
- Last Synced: 2024-11-07T07:13:16.661Z (5 months ago)
- Language: PowerShell
- Size: 1.39 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- jimsghstars - PowerShellCrack/MyAzureProfileScript - Profile script for your system to simply manage VMs in Azure (PowerShell)
README
# MyAzureProfileScript
A Profile script for your admin system to manage VMs in multiple (or singular) Azure tenants. I have multiple tenants and need to start them up based on what I am testing.
## Customize your resources
There are some areas that need to be modified. The very first function, __Set-MyAzureEnvironment__, is where the Azure tenants are configured; add the tenant info to each site. Review Lines 64-75
```powershell
#My Azure Site A lab
'Resource Tenant' {
$myTenantID = ''
$mySubscriptionName = ''
$mySubscriptionID = ''
$myResourceGroup = ''
}
#My Azure Site B lab
'Services Tenant' {
$myTenantID = ''
$mySubscriptionName = ''
$mySubscriptionID = ''
$myResourceGroup = ''
}
```Make sure to update _[ValidateSet()]_ in the param section (line 25) as well if you add new or change environments names.
```powershell
[ValidateSet('Resource Tenant','Services Tenant')]
```I have the script installs and updates the required modules. It currently monitors these modules:
- Az
- Azure
- AzureAD
- Az.SecurityI would recommend keeping the above
On line 29, you can edit it and add more if you like. :
```powershell
#set this to what you want
$Checkmodules = @('Az','Az.Security','Azure','AzureAD')
```## Call the script
Copy this script to your __C:\Users\\\\Documents\WindowsPowerShell__ folder and relaunch Windows PowerShell.
> __Keep in Mind__: If you already have a profile script, make sure you make a backup or integrate your code into this one.I've added a check to see if the script is called directly and if it is, it exits the script; this resolves issues with services calling powershell or VS code calling the script each time its launched
The only command you will need run is:
- Start-MyLabEnvironment
This will set off a chain of events
If you have not specified the correct Azure Tenant info, You will also be presented with a grid output to verify the subscription list.
Also the first time you connect to Azure using PowerShell, an identity file is creating in your profile. Being a nerd, the script parses that file to look for the authenticated username's first name and output a voice such as: "Good morning Dick, Please wait while I check for installed modules..."
However you can disable it if you set line 14 to
```powershell
$VoiceWelcomeMessage = $false$DefaultVoiceProfile = 'Female'
```
there are othere global settings that can be changes for more automation and features (lines 18-24)```powershell
$global:MyLabTag = 'StartupOrder'$global:MyAzLabTenant = 'Resource Tenant'
$global:MyMDTSimulatorPath = 'C:\MDTSimulator'
$global:MyDeploymentShare = "\\$env:ComputerName\Deploymentshare$"
```## Future changes
- I plan on making more voice commands within the functions; yes I know what your thinking...NERD ALERT!!## Screenshots
This is what the startup looks like.
NSG assigned to __subnet__ and only enabled JIT for VMs with public IP's
NSG assigned to VMs __nic__ and only enabled JIT for the ones with public IP's
## Functions Included
THe functions are the main functions to manage your virtual environment. However there are a lot of other functions available in this script:
UPDATE 06/11/2021: All command verbs will start with _My_
- **Start-MyLabEnvironment** --> Uses global variables start up lab. This will include starting Azure and Hyper-V labs and making sure Azure gateway IP is accurate. Only starts VM's with order tag specified in global variable. Set tag in notes of Hyper-V VM (eg: StartupOrder: 1)
- **Start-MyAzureEnvironment** --> Underlying function that will start the VM's in Azure environment
- Start-MyAzureVM
- Start-MyElevatedProcess
- Start-MyVSCodeInstall
- Start-MyHyperVM
- **Connect-MyAzureEnvironment** --> Starts just the Azure lab,
- Enable-MyAzureJitPolicy
- Get-MyAzureNSGRules
- Get-MyAzureUserName
- Get-MyAzureVM
- Get-MyHyperVM
- Get-MyRandomAlphanumericString
- Get-MyRandomSerialNumber
- Get-MyRemoteDesktopData
- Get-MyVolumeLevel
- Install-MyLatestModule
- Out-MyVoice
- Restart-MyHyperV
- Set-MyAzureEnvironment
- Set-MyAzureJitPolicy
- Set-MyVolumeLevel
- Set-MyWindowPosition
- Show-MyCommands
- Stop-MyHyperVM
- Test-MyVSCode
- Test-MyVSCodeInstallInstead of calling _powershell_ise_ using the alias _ise_. In this profile I set the alias of **vsc** to call _Microsoft Visual Studio_