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
# Login to Azure manually | |
Clear-AzureRmContext -Scope CurrentUser -Force | |
Login-AzureRmAccount -TenantId '<Your Azure Tenant ID>' # Microsoft | |
### Choose Subscription | |
$subscription = Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru | |
Select-AzureRmSubscription -SubscriptionId $subscription.id | |
# Fill in these variables |
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
################################################################################ | |
################## Compile the DSC Configuration & Generate the MOF file | |
################################################################################ | |
$ComputerName = $env:COMPUTERNAME | |
Main -nodeName $env:COMPUTERNAME -OutputPath "$env:USERPROFILE\Desktop" | |
################################################################################ | |
################## Apply the MOF file to the local computer | |
################################################################################ |
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
#region variables | |
# Replace with your Log Analytics Workspace ID | |
$CustomerID = '***************My Customer ID********************' | |
# Replace with your Log Analytics Workspace Primary Key | |
$SharedKey = '***************Massive Long Key********************' | |
# Specify the custom log name. | |
$LogType = '***************CustomLogName********************' # Name of the custom log Type=CustomLog_CL without the top and tail e.g. 'CustomLog' | |
# Specify a time in the format YYYY-MM-DDThh:mm:ssZ to specify a created time for the records | |
$TimeStampField = '' | |
#endregion |
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
#region Install Modules | |
# Run as Administrator | |
#Find-Module AzureServicePrincipalAccount | Install-Module | |
#endregion | |
# Retrieve Azure Module properties | |
"" | |
"Validating installed PowerShell Version and Azure PowerShell Module version..." |
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
<# | |
Written with version 2.8.0 of the Azure PowerShell Module | |
available from here https://github.com/Azure/azure-powershell/releases/tag/v2.8.0-October2019 | |
or run: Install-Module -Name Az -RequiredVersion 2.6.0 -AllowClobber | |
Migration instructions Azure.RM to Az - https://azure.microsoft.com/en-au/blog/how-to-migrate-from-azurerm-to-az-in-azure-powershell/ | |
#> | |
# from https://poshtools.com/2018/04/10/cross-platform-out-gridview-using-universal-dashboard/ | |
function Out-GridView | |
{ |
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
$RemoteMachines = '1598.domain.com', '1599.domain.com' | |
$adminname = 'user.name' | |
$adminpassword = 'YourPassword' | |
$password = ConvertTo-SecureString $adminpassword -AsPlainText -Force | |
$cred = New-Object System.Management.Automation.PSCredential (".\$adminname", $password) | |
$SessionOptions = New-PSSessionOption –SkipCACheck –SkipCNCheck –SkipRevocationCheck | |
$PSSession = New-PSSession -ComputerName $RemoteMachines -Port 5986 -UseSSL -Authentication Credssp -Credential $cred -SessionOption $SessionOptions | |
# Do stuff |
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
# This Sets up WinRM Remote PowerShell with delegated authentication while creating a self signed certificate | |
######################################################################## | |
################ Do this on the Server | |
######################################################################## | |
#Enable WinRM on a VM - with on-demand certificate creation | |
Function RemotePowerShell { | |
$process = 'cmd.exe' | |
$arguments = '/c winrm invoke restore winrm/config @{}' |
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
# This Sets up WinRM Remote PowerShell with delegated authentication for an existing trusted SSL cert | |
######################################################################## | |
################ Do this on the Server | |
######################################################################## | |
#Enable WinRM on a VM - with on-demand certificate creation | |
Function RemotePowerShell { | |
$process = 'cmd.exe' | |
$arguments = '/c winrm invoke restore winrm/config @{}' |
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-ScheduledTask -TaskPath "\" -TaskName Gracefully_Stop_Studio | Start-ScheduledTask |
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
$adminname = 'MyUser' | |
$adminpassword = 'password' | |
$taskName = "Start Studio" | |
$ShedService = New-Object -comobject 'Schedule.Service' | |
$ShedService.Connect() | |
$Task = $ShedService.NewTask(0) | |
$Task.RegistrationInfo.Description = $taskName | |
$Task.Settings.Enabled = $true |