This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Query AD tiering level from AD | |
Function Get-ADTieringLevel | |
{ | |
Param( | |
$ServerName | |
) | |
$OU = ([adsisearcher]"(&(name=$ServerName)(objectClass=computer))").FindOne().path | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add the AMA Extension - this may take a few minutes to run | |
$AMAExtension = @{ | |
Name = "AMAWindows" | |
ExtensionType = "AzureMonitorWindowsAgent" | |
Publisher = "Microsoft.Azure.Monitor" | |
ResourceGroupName = $ResourceGroup | |
MachineName = $ServerName | |
Location = $Location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Remove PowerShell session | |
Remove-PSSession -Session $PSRemoteSession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Onboard new server remotly | |
$ADTieringLevel = Get-ADTieringLevel -ServerName $ServerName | |
$Tags = @{ | |
"ADTieringLevel" = $ADTieringLevel; | |
} | |
$ResourceGroup = "RG-PROD-IT-AZURE-ARC-WE" | |
$Location = "West Europe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get the credentials and open a remote session | |
$ServerName = ("SRV02").ToUpper() | |
$Credentials = Get-Credential | |
$PSRemoteSession = New-PSSession -ComputerName $ServerName -Credential $Credentials | |
Write-Output "PowerShell remote session status: $($PSRemoteSession.State)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Query AD tiering level from AD | |
Function Get-ADTieringLevel | |
{ | |
Param( | |
$ServerName | |
) | |
$OU = ([adsisearcher]"(&(name=$ServerName)(objectClass=computer))").FindOne().path | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Connect Azure | |
Connect-AzAccount | |
#You may need to change the subscription co next(OPTIONAL) | |
Set-AzContext -Subscription XXXXX-XXXXX-XXXX-XXXX-XXXXXXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Module -Name Az.ConnectedMachine -Force -Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name Location ProvisioningState | |
---- -------- ----------------- | |
AMAWindows westeurope Succeeded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time="2021-09-18T21:01:35+03:00" level=info msg="Onboarding Machine. It usually takes a few minutes to complete. Sometimes it may take longer depending | |
on network and server load status." | |
time="2021-09-18T21:01:35+03:00" level=info msg="Check network connectivity to all endpoints..." | |
time="2021-09-18T21:01:36+03:00" level=info msg="All endpoints are available... continue onboarding" | |
time="2021-09-18T21:01:46+03:00" level=info msg="Successfully Onboarded Resource to Azure" VM Id=XXXXX-XXXX-XXXX-XXXX-XXXXXXXX | |
Get-AzConnectedMachine : The Resource 'Microsoft.HybridCompute/machines/ SRV02' under resource group 'RG-PROD-IT-AZURE-ARC-WE' was not found. For more | |
details please go to https://aka.ms/ARMResourceNotFoundFix | |
At C:\Program Files\WindowsPowerShell\Modules\Az.ConnectedMachine\0.2.0\custom\Connect-AzConnectedMachine.ps1:250 char:9 | |
+ Get-AzConnectedMachine -Name $Name -ResourceGroupName $Resour ... | |
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
NewerOlder