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)…

5

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