install OMS Log Analytics Agent and OMS Dependency Agent to all Windows VMs in the subscription using PowerShell

Save the following code as myscript.ps1 by replacing the ????? with the OMS workspaceid and OMS workspace key. Share the file using Storage Account Shared Access key as https:// function installOMS { param( [parameter(Mandatory=$true, HelpMessage=”OMS Log Analytics Workspace ID”)] [ValidateNotNullOrEmpty()] [string]$WorkSpaceID, [parameter(Mandatory=$true, HelpMessage=”OMS Log Analytics Workspace Key”)] [ValidateNotNullOrEmpty()] [string]$WorkSpaceKey ) $verboseactionoutput = “continue” # Set…

2

Post data to OMS Log Analytics Data Collector API using PowerShell

# Create the function to create and post the request Function Post-OMSData($customerId, $sharedKey, $body, $logType) { $method = “POST” $contentType = “application/json” $resource = “/api/logs” $rfc1123date = [DateTime]::UtcNow.ToString(“r”) $contentLength = $body.Length $signature = Build-Signature ` -customerId $customerId ` -sharedKey $sharedKey ` -date $rfc1123date ` -contentLength $contentLength ` -fileName $fileName ` -method $method ` -contentType $contentType…

0

The difference between [Switch] and[Bool] in Powershell function parameters

#switch parameter cls function MyAwesomeFunction1 { [CMDLetBinding()] param ( [string] $foo, [string] $bar, [switch] $someVariable ) Write-Host “someVariable = $someVariable” + $someVariable.GetType() if($someVariable) { Write-Host $foo } else { Write-Host $bar } } #boolean parameter function MyAwesomeFunction2 { [CMDLetBinding()] param ( [string] $foo, [string] $bar, [bool] $someVariable ) Write-Host “someVariable = $someVariable” + $someVariable.GetType() if($someVariable)…

4

How to deploy OMS Log Analytics Agent and Dependency Agent using DSC

# replace the ??????????? in the script Configuration MMAgent { $OIPackageLocalPath = “$env:temp\MMASetup-AMD64.exe” $SMapPackageLocalPath = “$env:temp\InstallDependencyAgent-Windows.exe” $OPSINSIGHTS_WS_ID = “??????????????” $OPSINSIGHTS_WS_KEY = “??????????????” Import-DscResource -ModuleName xPSDesiredStateConfiguration Node SQLnode { } Node OMSnode { Service OIService { Name = “HealthService” State = “Running” DependsOn = “[xPackage]OMSAgent” } Service DependencyService { Name = “MicrosoftDependencyAgent” State = “Running” DependsOn…

0

How to deploy OMS Log Analytics Agent and Dependency Agent to thousands of computers using PowerShell Workflow in parallel

workflow installOMS{ #fill in the computers.txt in temp folder as one computer per line with no delimeters $computers = inlinescript { $BaselineFile = “$env:temp\computers.txt” $lines = (Get-Content $BaselineFile) $computers = foreach ($line in $lines) { $line.Trim()} return $computers } parallel { inlinescript { try { $OPSINSIGHTS_WS_ID = “??????” $OPSINSIGHTS_WS_KEY = “?????” $arg1 = ‘/C:”setup.exe /qn…

0

Create new user via Microsoft Graph using PowerShell

cls # Load Active Directory Authentication Library (ADAL) Assemblies $adal = “${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll” $adalforms = “${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll” [System.Reflection.Assembly]::LoadFrom($adal) [System.Reflection.Assembly]::LoadFrom($adalforms) $cred = Get-Credential $mycred = new-object Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential($cred.UserName,$cred.Password) # Defining Azure AD tenant name, this is the name of your Azure Active Directory $adTenant = ”??????.onmicrosoft.com” $login = Add-AzureRmAccount -Credential $cred Get-AzureRmSubscription Select-AzureRmSubscription -SubscriptionID ‘??????‘ # Set…

0

user management using the AzureAD powershell module

cls $cred = Get-Credential #Connect to your AzureAD tenant Connect-AzureAD -Credential $cred # Get a user by UPN $user = Get-AzureADUser -ObjectId “user1@????.onmicrosoft.com” $user | fl # Update some properties $user = Set-AzureADUser -ObjectId $user.UserPrincipalName -Department “Azure Architecture” -Country “Turkey” # Get a user by UPN $user = Get-AzureADUser -ObjectId “user1@????.onmicrosoft.com” $user | fl

1

Managing Azure AD using Graph API and ADAL inside PowerShell

# replace ??????? before running the script cls # visit “https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/85/38/metablogapi/image_74154BB9.png” # Load Active Directory Authentication Library (ADAL) Assemblies $adal = “${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll” $adalforms = “${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll” [System.Reflection.Assembly]::LoadFrom($adal) [System.Reflection.Assembly]::LoadFrom($adalforms) $cred = Get-Credential $mycred = new-object Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential($cred.UserName,$cred.Password) # Defining Azure AD tenant name, this is the name of your Azure Active Directory $adTenant = ”bulentozkirhotmail.onmicrosoft.com” $login…

0

All about Office 365 Pro Plus deployment and updates

I have consolidated the most essential information about Office 365 Pro Plus deployment and updates in a single concise presentation. Please use it if you find it helpful. If there are any mistakes in this presentation, please let me know so that I can correct and republish it immediately. Office 365 ProPlus deployment and updates

2

Azure Resource Manager RBAC management practical tips

Please make sure that you have installed the latest Azure and Azure AD PowerShell libraries as I posted in my previous blogs. https://aka.ms/op0ndc First let’s login to Azure AD. $cred = Get-Credential Add-AzureRmAccount -Credential $mycred Select-AzureRmSubscription -SubscriptionID ‘???’ This script lists all the role definitions. Get-AzureRmRoleDefinition| Select-Object Name This script lists all possible actions for…

0