From 615f78f63cc09bf456e67f0f1bb99cad511d521d Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:35:02 -0400 Subject: [PATCH 1/6] Update all code formatting inline with style guidelines --- Build.ps1 | 19 +- Logic.Monitor.psd1 | 2 +- Private/Format-LMFilter.ps1 | 50 ++-- Private/New-LMHeader.ps1 | 14 +- Private/New-LMRandomCred.ps1 | 2 +- Private/Resolve-LMDebugInfo.ps1 | 2 +- Private/Resolve-LMException.ps1 | 8 +- Private/Update-LogicMonitorModule.ps1 | 12 +- Private/Write-LMHost.ps1 | 14 +- Public/Connect-LMAccount.ps1 | 106 ++++---- Public/Copy-LMDashboard.ps1 | 18 +- Public/Copy-LMDevice.ps1 | 32 +-- Public/Copy-LMReport.ps1 | 4 +- Public/Export-LMDeviceConfigBackup.ps1 | 22 +- Public/Export-LMDeviceData.ps1 | 36 +-- Public/Export-LMLogicModule.ps1 | 6 +- Public/Get-LMAPIToken.ps1 | 4 +- Public/Get-LMAccessGroup.ps1 | 2 +- Public/Get-LMAccountStatus.ps1 | 6 +- Public/Get-LMAlert.ps1 | 14 +- Public/Get-LMAlertRule.ps1 | 2 +- Public/Get-LMAppliesToFunction.ps1 | 2 +- Public/Get-LMAuditLogs.ps1 | 4 +- Public/Get-LMCachedAccount.ps1 | 16 +- Public/Get-LMCollector.ps1 | 2 +- Public/Get-LMCollectorGroup.ps1 | 2 +- Public/Get-LMCollectorInstaller.ps1 | 4 +- Public/Get-LMCollectorVersions.ps1 | 2 +- Public/Get-LMConfigSource.ps1 | 2 +- Public/Get-LMDashboard.ps1 | 2 +- Public/Get-LMDashboardGroup.ps1 | 2 +- Public/Get-LMDashboardWidget.ps1 | 2 +- Public/Get-LMDatasource.ps1 | 2 +- Public/Get-LMDatasourceAssociatedDevices.ps1 | 2 +- Public/Get-LMDatasourceGraph.ps1 | 32 +-- Public/Get-LMDatasourceMetadata.ps1 | 32 +-- Public/Get-LMDatasourceOverviewGraph.ps1 | 32 +-- Public/Get-LMDatasourceUpdateHistory.ps1 | 2 +- Public/Get-LMDevice.ps1 | 10 +- Public/Get-LMDeviceAlertSettings.ps1 | 8 +- Public/Get-LMDeviceAlerts.ps1 | 2 +- Public/Get-LMDeviceConfigSourceData.ps1 | 14 +- Public/Get-LMDeviceData.ps1 | 22 +- Public/Get-LMDeviceDataSourceList.ps1 | 2 +- Public/Get-LMDeviceDatasourceInstance.ps1 | 2 +- ...LMDeviceDatasourceInstanceAlertSetting.ps1 | 8 +- .../Get-LMDeviceDatasourceInstanceGroup.ps1 | 2 +- Public/Get-LMDeviceEventSourceList.ps1 | 2 +- Public/Get-LMDeviceGroup.ps1 | 6 +- Public/Get-LMDeviceGroupAlerts.ps1 | 2 +- ...et-LMDeviceGroupDatasourceAlertSetting.ps1 | 2 +- Public/Get-LMDeviceGroupDatasourceList.ps1 | 2 +- Public/Get-LMDeviceGroupDevices.ps1 | 6 +- Public/Get-LMDeviceGroupGroups.ps1 | 2 +- Public/Get-LMDeviceGroupProperty.ps1 | 2 +- Public/Get-LMDeviceGroupSDT.ps1 | 2 +- Public/Get-LMDeviceGroupSDTHistory.ps1 | 2 +- Public/Get-LMDeviceInstanceData.ps1 | 2 +- Public/Get-LMDeviceInstanceList.ps1 | 2 +- Public/Get-LMDeviceNetflowEndpoints.ps1 | 2 +- Public/Get-LMDeviceNetflowFlows.ps1 | 2 +- Public/Get-LMDeviceNetflowPorts.ps1 | 2 +- Public/Get-LMDeviceProperty.ps1 | 6 +- Public/Get-LMDeviceSDT.ps1 | 2 +- Public/Get-LMDeviceSDTHistory.ps1 | 2 +- Public/Get-LMEscalationChain.ps1 | 2 +- Public/Get-LMEventSource.ps1 | 2 +- Public/Get-LMIntegrationLogs.ps1 | 4 +- Public/Get-LMNetscan.ps1 | 2 +- Public/Get-LMNetscanExecution.ps1 | 6 +- Public/Get-LMNetscanExecutionDevices.ps1 | 8 +- Public/Get-LMNetscanGroup.ps1 | 2 +- Public/Get-LMOpsNote.ps1 | 2 +- Public/Get-LMPortalInfo.ps1 | 2 +- Public/Get-LMPropertySource.ps1 | 2 +- Public/Get-LMRecipientGroup.ps1 | 2 +- Public/Get-LMReport.ps1 | 2 +- Public/Get-LMReportGroup.ps1 | 2 +- Public/Get-LMRepositoryLogicModules.ps1 | 2 +- Public/Get-LMRole.ps1 | 2 +- Public/Get-LMSDT.ps1 | 2 +- Public/Get-LMTopologyMap.ps1 | 2 +- Public/Get-LMTopologySource.ps1 | 2 +- Public/Get-LMUnmonitoredDevice.ps1 | 2 +- Public/Get-LMUsageMetrics.ps1 | 2 +- Public/Get-LMUser.ps1 | 2 +- Public/Get-LMUserGroup.ps1 | 2 +- Public/Get-LMWebsite.ps1 | 2 +- Public/Get-LMWebsiteAlerts.ps1 | 2 +- Public/Get-LMWebsiteCheckpoint.ps1 | 2 +- Public/Get-LMWebsiteData.ps1 | 2 +- Public/Get-LMWebsiteGroup.ps1 | 2 +- Public/Get-LMWebsiteGroupAlerts.ps1 | 2 +- Public/Get-LMWebsiteGroupSDT.ps1 | 2 +- Public/Get-LMWebsiteGroupSDTHistory.ps1 | 2 +- Public/Get-LMWebsiteProperty.ps1 | 2 +- Public/Get-LMWebsiteSDT.ps1 | 2 +- Public/Get-LMWebsiteSDTHistory.ps1 | 2 +- Public/Import-LMDashboard.ps1 | 122 +++++----- Public/Import-LMExchangeModule.ps1 | 2 +- Public/Import-LMLogicModule.ps1 | 8 +- Public/Import-LMRepositoryLogicModules.ps1 | 8 +- Public/Invoke-LMActiveDiscovery.ps1 | 2 +- Public/Invoke-LMCloudGroupNetScan.ps1 | 4 +- Public/Invoke-LMCollectorDebugCommand.ps1 | 8 +- Public/New-LMAPIToken.ps1 | 4 +- Public/New-LMAlertAck.ps1 | 12 +- Public/New-LMAlertEscalation.ps1 | 8 +- Public/New-LMAlertNote.ps1 | 10 +- Public/New-LMAppliesToFunction.ps1 | 8 +- Public/New-LMCachedAccount.ps1 | 38 +-- Public/New-LMCollectorGroup.ps1 | 10 +- Public/New-LMDashboardGroup.ps1 | 10 +- Public/New-LMDatasourceGraph.ps1 | 2 +- Public/New-LMDatasourceOverviewGraph.ps1 | 8 +- Public/New-LMDevice.ps1 | 30 +-- Public/New-LMDeviceDatasourceInstance.ps1 | 2 +- .../New-LMDeviceDatasourceInstanceGroup.ps1 | 2 +- Public/New-LMDeviceDatasourceInstanceSDT.ps1 | 98 ++++---- Public/New-LMDeviceDatasourceSDT.ps1 | 98 ++++---- Public/New-LMDeviceGroup.ps1 | 2 +- Public/New-LMDeviceGroupSDT.ps1 | 98 ++++---- Public/New-LMDeviceProperty.ps1 | 2 +- Public/New-LMDeviceSDT.ps1 | 98 ++++---- Public/New-LMEnhancedNetscan.ps1 | 30 +-- Public/New-LMNetscanGroup.ps1 | 4 +- Public/New-LMOpsNote.ps1 | 28 +-- Public/New-LMPushMetricDataPoint.ps1 | 20 +- Public/New-LMPushMetricInstance.ps1 | 16 +- Public/New-LMReportGroup.ps1 | 4 +- Public/New-LMRole.ps1 | 224 ++++++++--------- Public/New-LMUser.ps1 | 14 +- Public/New-LMWebsite.ps1 | 50 ++-- Public/New-LMWebsiteGroup.ps1 | 2 +- Public/Remove-LMAPIToken.ps1 | 18 +- Public/Remove-LMAppliesToFunction.ps1 | 12 +- Public/Remove-LMCachedAccount.ps1 | 22 +- Public/Remove-LMCollectorGroup.ps1 | 10 +- Public/Remove-LMConfigsource.ps1 | 18 +- Public/Remove-LMDashboard.ps1 | 18 +- Public/Remove-LMDashboardGroup.ps1 | 18 +- Public/Remove-LMDashboardWidget.ps1 | 18 +- Public/Remove-LMDatasource.ps1 | 16 +- Public/Remove-LMDevice.ps1 | 12 +- Public/Remove-LMDeviceDatasourceInstance.ps1 | 18 +- Public/Remove-LMDeviceGroup.ps1 | 10 +- Public/Remove-LMDeviceProperty.ps1 | 12 +- Public/Remove-LMNetscan.ps1 | 18 +- Public/Remove-LMNetscanGroup.ps1 | 12 +- Public/Remove-LMOpsNote.ps1 | 6 +- Public/Remove-LMPropertysource.ps1 | 18 +- Public/Remove-LMReport.ps1 | 12 +- Public/Remove-LMReportGroup.ps1 | 12 +- Public/Remove-LMRole.ps1 | 12 +- Public/Remove-LMSDT.ps1 | 6 +- Public/Remove-LMTopologysource.ps1 | 18 +- Public/Remove-LMUnmonitoredDevice.ps1 | 4 +- Public/Remove-LMUser.ps1 | 12 +- Public/Remove-LMWebsite.ps1 | 18 +- Public/Remove-LMWebsiteGroup.ps1 | 12 +- Public/Send-LMPushMetric.ps1 | 20 +- Public/Set-LMAPIToken.ps1 | 12 +- Public/Set-LMAppliesToFunction.ps1 | 16 +- Public/Set-LMCollector.ps1 | 8 +- Public/Set-LMCollectorConfig.ps1 | 88 +++---- Public/Set-LMCollectorGroup.ps1 | 20 +- Public/Set-LMConfigsource.ps1 | 24 +- Public/Set-LMDatasource.ps1 | 22 +- Public/Set-LMDevice.ps1 | 8 +- Public/Set-LMDeviceDatasourceInstance.ps1 | 14 +- ...LMDeviceDatasourceInstanceAlertSetting.ps1 | 34 +-- Public/Set-LMDeviceGroup.ps1 | 8 +- ...et-LMDeviceGroupDatasourceAlertSetting.ps1 | 24 +- Public/Set-LMDeviceProperty.ps1 | 6 +- Public/Set-LMNetscanGroup.ps1 | 4 +- Public/Set-LMNewUserMessage.ps1 | 4 +- Public/Set-LMOpsNote.ps1 | 32 +-- Public/Set-LMPortalInfo.ps1 | 24 +- Public/Set-LMPropertysource.ps1 | 14 +- Public/Set-LMPushModuleDeviceProperty.ps1 | 10 +- Public/Set-LMPushModuleInstanceProperty.ps1 | 14 +- Public/Set-LMReportGroup.ps1 | 4 +- Public/Set-LMRole.ps1 | 226 +++++++++--------- Public/Set-LMSDT.ps1 | 32 +-- Public/Set-LMTopologysource.ps1 | 18 +- Public/Set-LMUnmonitoredDevice.ps1 | 6 +- Public/Set-LMWebsite.ps1 | 30 +-- Tests/LMDevice.Tests.ps1 | 4 +- Tests/LMDeviceGroup.Tests.ps1 | 4 +- Tests/LMOpsNotes.Tests.ps1 | 8 +- Tests/LMUser-Role.Tests.ps1 | 2 +- Tests/LMWebsite.Tests.ps1 | 6 +- Tests/LMWebsiteGroup.Tests.ps1 | 4 +- 193 files changed, 1456 insertions(+), 1455 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index 5a4d32a..f7b2e98 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -7,25 +7,25 @@ $publicFuncFolderPath = './Public' $ps1xmlFiles = Get-ChildItem -Path ./ -Filter *.ps1xml foreach ($ps1xml in $ps1xmlFiles) { - [xml]$xml = Get-Content -Path $ps1xml.FullName - $null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Format.xsd') - $null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Types.xsd') - $xml.Validate( { throw "File '$($ps1xml.Name)' schema error: $($_.Message)" }) + [xml]$xml = Get-Content -Path $ps1xml.FullName + $null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Format.xsd') + $null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Types.xsd') + $xml.Validate( { throw "File '$($ps1xml.Name)' schema error: $($_.Message)" }) } if (!(Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' })) { - Install-PackageProvider -Name NuGet -force | Out-Null + Install-PackageProvider -Name NuGet -Force | Out-Null } -Import-PackageProvider -Name NuGet -force | Out-Null +Import-PackageProvider -Name NuGet -Force | Out-Null if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted } -if(!(Get-Module Microsoft.PowerShell.SecretManagement -ListAvailable)){ +if (!(Get-Module Microsoft.PowerShell.SecretManagement -ListAvailable)) { Install-Module Microsoft.PowerShell.SecretManagement -Force -Confirm:$false } -if(!(Get-Module Microsoft.PowerShell.SecretStore -ListAvailable)){ +if (!(Get-Module Microsoft.PowerShell.SecretStore -ListAvailable)) { Install-Module Microsoft.PowerShell.SecretStore -Force -Confirm:$false } @@ -33,7 +33,8 @@ $manifestContent = (Get-Content -Path $manifestPath -Raw) -replace ' Function Connect-LMAccount { - [CmdletBinding(DefaultParameterSetName="LMv1")] + [CmdletBinding(DefaultParameterSetName = "LMv1")] Param ( [Parameter(Mandatory, ParameterSetName = 'LMv1')] [String]$AccessId, @@ -87,8 +87,8 @@ Function Connect-LMAccount { ) #Autoload web assembly if on older version of powershell - If((Get-Host).Version.Major -lt 6){ - Add-type -AssemblyName System.Web + If ((Get-Host).Version.Major -lt 6) { + Add-Type -AssemblyName System.Web } If ($UseCachedCredential -or $CachedAccountName) { @@ -98,7 +98,7 @@ Function Connect-LMAccount { Write-Host "[INFO]: Existing vault Logic.Monitor already exists, skipping creation" } Catch { - If($_.Exception.Message -like "*Vault Logic.Monitor does not exist in registry*") { + If ($_.Exception.Message -like "*Vault Logic.Monitor does not exist in registry*") { Write-Host "[INFO]: Credential vault for cached accounts does not currently exist, creating credential vault: Logic.Monitor" Register-SecretVault -Name Logic.Monitor -ModuleName Microsoft.PowerShell.SecretStore Get-SecretStoreConfiguration | Out-Null @@ -112,58 +112,58 @@ Function Connect-LMAccount { Foreach ($Credential in $CredentialFile) { $CurrentDate = Get-Date [Hashtable]$Metadata = @{ - Portal = [String]$Credential.Portal - Id = [String]$Credential.Id - Modified = [DateTime]$CurrentDate + Portal = [String]$Credential.Portal + Id = [String]$Credential.Id + Modified = [DateTime]$CurrentDate } - Try{ + Try { Set-Secret -Name $Credential.Portal -Secret $Credential.Key -Vault Logic.Monitor -Metadata $Metadata -NoClobber Write-Host "[INFO]: Successfully migrated cached account secret for portal: $($Credential.Portal)" } - Catch{ + Catch { Write-Error $_.Exception.Message $MigrationComplete = $false } } - If($MigrationComplete){ + If ($MigrationComplete) { Remove-Item -Path $CredentialPath -Confirm:$false Write-Host "[INFO]: Successfully migrated cached accounts into secret store, your legacy account cache hes been removed." } - Else{ + Else { $NewName = Join-Path -Path $Home -ChildPath "Logic.Monitor-Migrated.json" Rename-Item -Path $CredentialPath -Confirm:$false -NewName $NewName Write-Host "[ERROR]: Unable to fully migrate cached accounts into secret store, your legacy account cache has been archived at: $NewName. No other attemps will be made to migrate any failed accounts." -ForegroundColor Red } } - If($CachedAccountName){ + If ($CachedAccountName) { #If supplied and account name just use that vs showing a list of accounts $CachedAccountSecrets = Get-SecretInfo -Vault Logic.Monitor $CachedAccountIndex = $CachedAccountSecrets.Name.IndexOf($CachedAccountName) - If($CachedAccountIndex -ne -1){ + If ($CachedAccountIndex -ne -1) { $AccountName = $CachedAccountSecrets[$CachedAccountIndex].Metadata["Portal"] $AccessId = $CachedAccountSecrets[$CachedAccountIndex].Metadata["Id"] $Type = $CachedAccountSecrets[$CachedAccountIndex].Metadata["Type"] - If(($Type -eq "LMv1") -or ($null -eq $Type)){ + If (($Type -eq "LMv1") -or ($null -eq $Type)) { [SecureString]$AccessKey = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString } - Else{ + Else { [SecureString]$BearerToken = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString } } - Else{ + Else { Write-Error "Entered CachedAccountName ($CachedAccountName) does not match one of the stored credentials, please check the selected entry and try again" Return } } - Else{ + Else { #List out current portals with saved credentials and let users chose which to use $i = 0 $CachedAccountSecrets = Get-SecretInfo -Vault Logic.Monitor - If($CachedAccountSecrets){ + If ($CachedAccountSecrets) { Write-Host "Selection Number | Portal Name" Foreach ($Credential in $CachedAccountSecrets) { - If($Credential.Name -notlike "*LMSessionSync*"){ + If ($Credential.Name -notlike "*LMSessionSync*") { Write-Host "$i) $($Credential.Name)" } $i++ @@ -174,13 +174,13 @@ Function Connect-LMAccount { $CachedAccountName = $CachedAccountSecrets[$StoredCredentialIndex].Name $AccessId = $CachedAccountSecrets[$StoredCredentialIndex].Metadata["Id"] $Type = $CachedAccountSecrets[$StoredCredentialIndex].Metadata["Type"] - If($Type -eq "LMv1"){ + If ($Type -eq "LMv1") { [SecureString]$AccessKey = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString } - ElseIf($Type -eq "Bearer"){ + ElseIf ($Type -eq "Bearer") { [SecureString]$BearerToken = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString } - Else{ + Else { Write-Error "Invalid credential type detected for selection: $Type" Return } @@ -190,72 +190,72 @@ Function Connect-LMAccount { Return } } - Else{ + Else { Write-Error "No entries currently found in secret vault Logic.Monitor" - Return + Return } } } Else { - If($PsCmdlet.ParameterSetName -eq "LMv1"){ + If ($PsCmdlet.ParameterSetName -eq "LMv1") { #Convert to secure string [SecureString]$AccessKey = $AccessKey | ConvertTo-SecureString -AsPlainText -Force $Type = "LMv1" } - ElseIf($PsCmdlet.ParameterSetName -eq "SessionSync"){ + ElseIf ($PsCmdlet.ParameterSetName -eq "SessionSync") { $Session = Get-LMSession -AccountName $AccountName - If($Session){ - $AccessId = $Session.jSessionID #Session Id - $AccessKey = $Session.token #CSRF Token + If ($Session) { + $AccessId = $Session.jSessionID #Session Id + $AccessKey = $Session.token #CSRF Token $Type = "SessionSync" } - Else{ + Else { throw "Unable to validate session sync info for: $AccountName" } } - Else{ + Else { #Convert to secure string [SecureString]$BearerToken = $BearerToken | ConvertTo-SecureString -AsPlainText -Force $Type = "Bearer" } } - If(!$Type){ + If (!$Type) { $Type = "LMv1" } #Create Credential Object for reuse in other functions $Script:LMAuth = [PSCustomObject]@{ - Id = $AccessId - Key = $AccessKey - BearerToken = $BearerToken - Portal = $AccountName - Valid = $true - Logging = !$DisableConsoleLogging.IsPresent - Type = $Type + Id = $AccessId + Key = $AccessKey + BearerToken = $BearerToken + Portal = $AccountName + Valid = $true + Logging = !$DisableConsoleLogging.IsPresent + Type = $Type } #Check for newer version of Logic.Monitor module - Try{ - If($AutoUpdateModuleVersion -and !$SkipVersionCheck){ + Try { + If ($AutoUpdateModuleVersion -and !$SkipVersionCheck) { Update-LogicMonitorModule } - ElseIf(!$SkipVersionCheck){ + ElseIf (!$SkipVersionCheck) { Update-LogicMonitorModule -CheckOnly } } - Catch{ + Catch { Write-Host "[ERROR]: Unable to check for newer version of Logic.Monitor module: $($_.Exception.Message)" -ForegroundColor Red } - If(!$SkipCredValidation){ + If (!$SkipCredValidation) { Try { #Collect portal info and api username and roles - If($Type -eq "Bearer"){ + If ($Type -eq "Bearer") { $Token = [System.Net.NetworkCredential]::new("", $BearerToken).Password - $ApiInfo = Get-LMAPIToken -Type Bearer -ErrorAction SilentlyContinue | Where-Object {$_.accessKey -like "$($Token.Substring(0,20))*"} + $ApiInfo = Get-LMAPIToken -Type Bearer -ErrorAction SilentlyContinue | Where-Object { $_.accessKey -like "$($Token.Substring(0,20))*" } } - Else{ + Else { $ApiInfo = Get-LMAPIToken -Filter "accessId -eq '$AccessId'" -ErrorAction SilentlyContinue } @@ -265,7 +265,7 @@ Function Connect-LMAccount { Return } Else { - Try{ + Try { $PortalInfo = Get-LMPortalInfo -ErrorAction Stop Write-LMHost "[INFO]: Connected to LM portal $($PortalInfo.companyDisplayName) via $Type Token - ($($PortalInfo.numberOfDevices) devices | $($PortalInfo.numOfWebsites) websites)." -ForegroundColor Green Return @@ -276,18 +276,18 @@ Function Connect-LMAccount { } } Catch { - Try{ + Try { $DeviceInfo = Get-LMDevice -ErrorAction Stop - If($DeviceInfo){ + If ($DeviceInfo) { Write-LMHost "[INFO]: Connected to LM portal $AccountName via $Type Token with limited permissions, ensure your api token has the necessary rights needed to run desired commands." -ForegroundColor Yellow Return } - Else{ + Else { throw "Unable to verify api token permission levels, ensure api token has rights to view all/select resources or at minimum view access for Account Information" } } - Catch{ + Catch { #Clear credential object from environment Remove-Variable LMAuth -Scope Script -ErrorAction SilentlyContinue @@ -296,7 +296,7 @@ Function Connect-LMAccount { Return } } - Else{ + Else { Write-LMHost "[INFO]: Skipping validation of credentials, connected to LM portal $AccountName via $Type, ensure your api token has the necessary rights needed to run desired commands." -ForegroundColor Yellow } } diff --git a/Public/Copy-LMDashboard.ps1 b/Public/Copy-LMDashboard.ps1 index 77798d2..738d831 100644 --- a/Public/Copy-LMDashboard.ps1 +++ b/Public/Copy-LMDashboard.ps1 @@ -76,7 +76,7 @@ Function Copy-LMDashboard { } #Lookup Dashboard Id - If($DashboardName) { + If ($DashboardName) { $LookupResult = (Get-LMDashboard -Name $DashboardName).Id If (Test-LookupResult -Result $LookupResult -LookupString $DashboardName) { return @@ -92,13 +92,13 @@ Function Copy-LMDashboard { Try { $Data = @{ - name = $Name - description = $Description - groupId = $ParentGroupId - widgetTokens = $SourceDashboard.widgetTokens - widgetsConfig = $SourceDashboard.widgetsConfig - widgetsOrder = $SourceDashboard.widgetsOrder - sharable = $SourceDashboard.sharable + name = $Name + description = $Description + groupId = $ParentGroupId + widgetTokens = $SourceDashboard.widgetTokens + widgetsConfig = $SourceDashboard.widgetsConfig + widgetsOrder = $SourceDashboard.widgetsOrder + sharable = $SourceDashboard.sharable } $Data = ($Data | ConvertTo-Json) @@ -108,7 +108,7 @@ Function Copy-LMDashboard { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/Copy-LMDevice.ps1 b/Public/Copy-LMDevice.ps1 index 682c8c1..4f59752 100644 --- a/Public/Copy-LMDevice.ps1 +++ b/Public/Copy-LMDevice.ps1 @@ -47,25 +47,25 @@ Function Copy-LMDevice { Process { If ($Script:LMAuth.Valid) { #Strip out dynamic groups - $HostGroupIds = ($DeviceObjec.hostGroupIds -Split "," | Get-LMDeviceGroup | Where-Object {$_.appliesTo -eq ""}).Id -Join "," + $HostGroupIds = ($DeviceObjec.hostGroupIds -Split "," | Get-LMDeviceGroup | Where-Object { $_.appliesTo -eq "" }).Id -Join "," $Data = @{ - name = $Name - displayName = If($DisplayName){$DisplayName}Else{$DeviceObject.displayName} - description = If($Description){$Description}Else{$DeviceObject.description} - disableAlerting = $DeviceObject.disableAlerting - enableNetflow = $DeviceObject.enableNetFlow - customProperties = $DeviceObject.customProperties - deviceType = $DeviceObject.deviceType - preferredCollectorId = $DeviceObject.preferredCollectorId - preferredCollectorGroupId = $DeviceObject.preferredCollectorGroupId + name = $Name + displayName = If ($DisplayName) { $DisplayName }Else { $DeviceObject.displayName } + description = If ($Description) { $Description }Else { $DeviceObject.description } + disableAlerting = $DeviceObject.disableAlerting + enableNetflow = $DeviceObject.enableNetFlow + customProperties = $DeviceObject.customProperties + deviceType = $DeviceObject.deviceType + preferredCollectorId = $DeviceObject.preferredCollectorId + preferredCollectorGroupId = $DeviceObject.preferredCollectorGroupId autoBalancedCollectorGroupId = $DeviceObject.autoBalancedCollectorGroupId - link = $DeviceObject.link - netflowCollectorGroupId = $DeviceObject.netflowCollectorGroupId - netflowCollectorId = $DeviceObject.netflowCollectorId - logCollectorGroupId = $DeviceObject.logCollectorGroupId - logCollectorId = $DeviceObject.logCollectorId - hostGroupIds = If($HostGroupIds){$HostGroupIds}Else{1} + link = $DeviceObject.link + netflowCollectorGroupId = $DeviceObject.netflowCollectorGroupId + netflowCollectorId = $DeviceObject.netflowCollectorId + logCollectorGroupId = $DeviceObject.logCollectorGroupId + logCollectorId = $DeviceObject.logCollectorId + hostGroupIds = If ($HostGroupIds) { $HostGroupIds }Else { 1 } } #Build header and uri diff --git a/Public/Copy-LMReport.ps1 b/Public/Copy-LMReport.ps1 index 09be999..8295901 100644 --- a/Public/Copy-LMReport.ps1 +++ b/Public/Copy-LMReport.ps1 @@ -48,8 +48,8 @@ Function Copy-LMReport { #Replace name and description if present $ReportObject.name = $Name - If($Description){$ReportObject.description = $Description} - If($ParentGroupId){$ReportObject.groupId = $ParentGroupId} + If ($Description) { $ReportObject.description = $Description } + If ($ParentGroupId) { $ReportObject.groupId = $ParentGroupId } #Build header and uri $ResourcePath = "/report/reports" diff --git a/Public/Export-LMDeviceConfigBackup.ps1 b/Public/Export-LMDeviceConfigBackup.ps1 index d846729..4deaaf3 100644 --- a/Public/Export-LMDeviceConfigBackup.ps1 +++ b/Public/Export-LMDeviceConfigBackup.ps1 @@ -39,12 +39,12 @@ PSGallery: https://www.powershellgallery.com/packages/Logic.Monitor Function Export-LMDeviceConfigBackup { - [CmdletBinding(DefaultParameterSetName="Device")] + [CmdletBinding(DefaultParameterSetName = "Device")] Param ( - [Parameter(ParameterSetName="DeviceGroup",Mandatory)] + [Parameter(ParameterSetName = "DeviceGroup", Mandatory)] [Int]$DeviceGroupId, - [Parameter(ParameterSetName="Device",Mandatory)] + [Parameter(ParameterSetName = "Device", Mandatory)] [Int]$DeviceId, [Regex]$InstanceNameFilter = "[rR]unning|[cC]urrent|[pP]aloAlto", @@ -58,7 +58,7 @@ Function Export-LMDeviceConfigBackup { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($DeviceId){ + If ($DeviceId) { $network_devices = Get-LMDevice -id $DeviceId } Else { @@ -77,9 +77,9 @@ Function Export-LMDeviceConfigBackup { $filtered_config_instance_count = 0 Foreach ($config_source in $device_config_sources) { $running_config_instance = Get-LMDeviceDatasourceInstance -DeviceId $config_source.deviceId -DatasourceId $config_source.dataSourceId - $filtered_config_instance = $running_config_instance | Where-Object { $_.displayName -Match $InstanceNameFilter} + $filtered_config_instance = $running_config_instance | Where-Object { $_.displayName -Match $InstanceNameFilter } If ($filtered_config_instance) { - Foreach($instance in $filtered_config_instance){ + Foreach ($instance in $filtered_config_instance) { $filtered_config_instance_count++ $instance_list += [PSCustomObject]@{ deviceId = $device.id @@ -94,7 +94,7 @@ Function Export-LMDeviceConfigBackup { } } } - Write-LMHost " [INFO]: Found $filtered_config_instance_count configsource instance(s) using match filter ($InstanceNameFilter)." -ForegroundColor Gray + Write-LMHost " [INFO]: Found $filtered_config_instance_count configsource instance(s) using match filter ($InstanceNameFilter)." -ForegroundColor Gray } #Loop through filtered instance list and pull config diff @@ -112,7 +112,7 @@ Function Export-LMDeviceConfigBackup { #Loop through each set and built report Foreach ($device in $config_grouping) { $config = $device.Group | Sort-Object -Property pollTimestamp -Descending | Select-Object -First 1 - Write-LMHost " [INFO]: Found $(($device.Group | Measure-Object).Count) configsource instance version(s) for: $($config.deviceDisplayName), selecting latest config dated: $([datetimeoffset]::FromUnixTimeMilliseconds($config.pollTimestamp).DateTime)UTC" -ForegroundColor Gray + Write-LMHost " [INFO]: Found $(($device.Group | Measure-Object).Count) configsource instance version(s) for: $($config.deviceDisplayName), selecting latest config dated: $([datetimeoffset]::FromUnixTimeMilliseconds($config.pollTimestamp).DateTime)UTC" -ForegroundColor Gray $output_list += [PSCustomObject]@{ deviceDisplayName = $config.deviceDisplayName deviceInstanceName = $config.instanceName @@ -125,14 +125,14 @@ Function Export-LMDeviceConfigBackup { } } - If($output_list){ - If($Path){ + If ($output_list) { + If ($Path) { #Generate CSV Export $output_list | Export-Csv -Path $Path -NoTypeInformation } Return (Add-ObjectTypeInfo -InputObject $output_list -TypeName "LogicMonitor.ConfigBackup" ) } - Else{ + Else { Write-LMHost "[WARN]: Did not find any configs to output based on selected resource(s), check your parameters and try again." -ForegroundColor Yellow } diff --git a/Public/Export-LMDeviceData.ps1 b/Public/Export-LMDeviceData.ps1 index 04ed5b6..07a20c4 100644 --- a/Public/Export-LMDeviceData.ps1 +++ b/Public/Export-LMDeviceData.ps1 @@ -86,7 +86,7 @@ Function Export-LMDeviceData { If ($Script:LMAuth.Valid) { $DeviceList = @() $DataExportList = @() - Switch($PSCmdlet.ParameterSetName){ + Switch ($PSCmdlet.ParameterSetName) { "DeviceId" { $DeviceList = Get-LMDevice -Id $DeviceId } "DeviceName" { $DeviceList = Get-LMDevice -DisplayName $DeviceName } "DeviceHostName" { $DeviceList = Get-LMDevice -Name $DeviceHostName } @@ -94,33 +94,33 @@ Function Export-LMDeviceData { "DeviceGroupName" { $DeviceList = Get-LMDeviceGroupDevices -Name $DeviceGroupName } } - If($DeviceList){ + If ($DeviceList) { Write-LMHost "[INFO]: $(($DeviceList | Measure-Object).count) resource(s) selected for data export" - Foreach($Device in $DeviceList){ + Foreach ($Device in $DeviceList) { $DatasourceList = @() Write-LMHost "[INFO]: Starting data collection for resource: $($Device.displayName)" - $DatasourceList = Get-LMDeviceDatasourceList -Id $Device.id | Where-Object { $_.monitoringInstanceNumber -gt 0 -and $_.dataSourceName -like $DatasourceIncludeFilter -and $_.datasourceName -notlike $DatasourceExcludeFilter} - If($DatasourceList){ + $DatasourceList = Get-LMDeviceDatasourceList -Id $Device.id | Where-Object { $_.monitoringInstanceNumber -gt 0 -and $_.dataSourceName -like $DatasourceIncludeFilter -and $_.datasourceName -notlike $DatasourceExcludeFilter } + If ($DatasourceList) { Write-LMHost "[INFO]: Found ($(($DatasourceList | Measure-Object).count)) datasource(s) with 1 or more active instances for resource: $($Device.displayName) using datasource filter (Include:$DatasourceIncludeFilter | Exclude:$DatasourceExcludeFilter)" - Foreach($Datasource in $DatasourceList){ + Foreach ($Datasource in $DatasourceList) { Write-LMHost "[INFO]: Starting instance discovery for datasource $($Datasource.dataSourceName) for resource: $($Device.displayName)" $InstanceList = @() - $InstanceList = Get-LMDeviceDatasourceInstance -Id $Device.id -DatasourceId $Datasource.dataSourceId | Where-Object { $_.stopMonitoring -eq $false} - If($InstanceList){ + $InstanceList = Get-LMDeviceDatasourceInstance -Id $Device.id -DatasourceId $Datasource.dataSourceId | Where-Object { $_.stopMonitoring -eq $false } + If ($InstanceList) { Write-LMHost "[INFO]: Found ($(($InstanceList | Measure-Object).count)) instance(s) for resource: $($Device.displayName)" - Foreach($Instance in $InstanceList){ + Foreach ($Instance in $InstanceList) { Write-LMHost "[INFO]: Starting datapoint collection for instance $($Instance.name) for resource: $($Device.displayName)" $Datapoints = @() $Datapoints = Get-LMDeviceData -DeviceId $Device.id -DatasourceId $Datasource.dataSourceId -InstanceId $Instance.id -StartDate $StartDate -EndDate $EndDate - If($Datapoints){ + If ($Datapoints) { Write-LMHost "[INFO]: Finished datapoint collection for instance $($Instance.name) for resource: $($Device.displayName)" $DataExportList += [PSCustomObject]@{ - deviceId = $Device.id - deviceName = $Device.displayName + deviceId = $Device.id + deviceName = $Device.displayName datasourceName = $Datasource.dataSourceName - instanceName = $Instance.name - instanceGroup = $Instance.groupName - dataPoints = $Datapoints + instanceName = $Instance.name + instanceGroup = $Instance.groupName + dataPoints = $Datapoints } } } @@ -129,13 +129,13 @@ Function Export-LMDeviceData { } } - Switch($ExportFormat){ + Switch ($ExportFormat) { "json" { $DataExportList | ConvertTo-Json -Depth 3 | Out-File -FilePath "$ExportPath\LMDeviceDataExport.json" ; return } - "csv" { $DataExportList | Export-Csv -NoTypeInformation -Path "$ExportPath\LMDeviceDataExport.csv" ; return } + "csv" { $DataExportList | Export-Csv -NoTypeInformation -Path "$ExportPath\LMDeviceDataExport.csv" ; return } default { return $DataExportList } } } - Else{ + Else { Write-Error "No resources found using supplied parameters, please check you settings and try again." } diff --git a/Public/Export-LMLogicModule.ps1 b/Public/Export-LMLogicModule.ps1 index 3bf032b..92ab99f 100644 --- a/Public/Export-LMLogicModule.ps1 +++ b/Public/Export-LMLogicModule.ps1 @@ -52,10 +52,10 @@ Function Export-LMLogicModule { [String]$DownloadPath = (Get-Location).Path ) - Begin{ + Begin { } - Process{ + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -155,5 +155,5 @@ Function Export-LMLogicModule { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Get-LMAPIToken.ps1 b/Public/Get-LMAPIToken.ps1 index 7767888..cc3629d 100644 --- a/Public/Get-LMAPIToken.ps1 +++ b/Public/Get-LMAPIToken.ps1 @@ -65,7 +65,7 @@ Function Get-LMAPIToken { [ValidateSet("LMv1", "Bearer", "*")] [String]$Type = "*", - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -80,7 +80,7 @@ Function Get-LMAPIToken { $Done = $false $Results = @() - If($Type -eq "Bearer"){ + If ($Type -eq "Bearer") { $BearerParam = "&type=bearer" } diff --git a/Public/Get-LMAccessGroup.ps1 b/Public/Get-LMAccessGroup.ps1 index 58bbdb0..5c3b08f 100644 --- a/Public/Get-LMAccessGroup.ps1 +++ b/Public/Get-LMAccessGroup.ps1 @@ -45,7 +45,7 @@ Function Get-LMAccessGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMAccountStatus.ps1 b/Public/Get-LMAccountStatus.ps1 index 315093c..ad530db 100644 --- a/Public/Get-LMAccountStatus.ps1 +++ b/Public/Get-LMAccountStatus.ps1 @@ -26,10 +26,10 @@ Function Get-LMAccountStatus { #Clear credential object from environment If ($Script:LMAuth) { $Result = [PSCustomObject]@{ - Portal = $Script:LMAuth.Portal - Valid = $Script:LMAuth.Valid + Portal = $Script:LMAuth.Portal + Valid = $Script:LMAuth.Valid Logging = $Script:LMAuth.Logging - Type = $Script:LMAuth.Type + Type = $Script:LMAuth.Type } return $Result } diff --git a/Public/Get-LMAlert.ps1 b/Public/Get-LMAlert.ps1 index 27c2381..ef93c51 100644 --- a/Public/Get-LMAlert.ps1 +++ b/Public/Get-LMAlert.ps1 @@ -56,13 +56,13 @@ Function Get-LMAlert { [Parameter(ParameterSetName = 'Range')] [Datetime]$EndDate, - [Parameter(Mandatory,ParameterSetName = 'Id')] + [Parameter(Mandatory, ParameterSetName = 'Id')] [String]$Id, [ValidateSet("*", "Warning", "Error", "Critical")] [String]$Severity = "*", - [ValidateSet("*", "websiteAlert", "dataSourceAlert", "eventSourceAlert","logAlert")] + [ValidateSet("*", "websiteAlert", "dataSourceAlert", "eventSourceAlert", "logAlert")] [String]$Type = "*", [Boolean]$ClearedAlerts = $false, @@ -73,7 +73,7 @@ Function Get-LMAlert { [Parameter(ParameterSetName = 'Id')] [String[]]$CustomColumns, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000, [String]$Sort = "resourceId" @@ -116,16 +116,16 @@ Function Get-LMAlert { $resourcePath += "/$Id" #Check if we need to add customColumns - If($CustomColumns){ + If ($CustomColumns) { $FormatedColumns = @() - Foreach($Column in $CustomColumns){ + Foreach ($Column in $CustomColumns) { $FormatedColumns += [System.Web.HTTPUtility]::UrlEncode($Column) } - If($QueryParams){ + If ($QueryParams) { $QueryParams += "&customColumns=$($FormatedColumns -join ",")" } - Else{ + Else { $QueryParams = "?customColumns=$($FormatedColumns -join",")" } } diff --git a/Public/Get-LMAlertRule.ps1 b/Public/Get-LMAlertRule.ps1 index 9132403..0dcac71 100644 --- a/Public/Get-LMAlertRule.ps1 +++ b/Public/Get-LMAlertRule.ps1 @@ -41,7 +41,7 @@ Function Get-LMAlertRule { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMAppliesToFunction.ps1 b/Public/Get-LMAppliesToFunction.ps1 index 233ce49..0025770 100644 --- a/Public/Get-LMAppliesToFunction.ps1 +++ b/Public/Get-LMAppliesToFunction.ps1 @@ -49,7 +49,7 @@ Function Get-LMAppliesToFunction { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMAuditLogs.ps1 b/Public/Get-LMAuditLogs.ps1 index 55e562d..9e5e2c7 100644 --- a/Public/Get-LMAuditLogs.ps1 +++ b/Public/Get-LMAuditLogs.ps1 @@ -53,7 +53,7 @@ Function Get-LMAuditLogs { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -71,7 +71,7 @@ Function Get-LMAuditLogs { #Convert to epoch, if not set use defaults If (!$StartDate) { - If($PSCmdlet.ParameterSetName -ne "Id"){ + If ($PSCmdlet.ParameterSetName -ne "Id") { Write-LMHost "[WARN]: No start date specified, defaulting to last 30 days" -ForegroundColor Yellow } [int]$StartDate = ([DateTimeOffset]$(Get-Date).AddDays(-30)).ToUnixTimeSeconds() diff --git a/Public/Get-LMCachedAccount.ps1 b/Public/Get-LMCachedAccount.ps1 index 7c2ae5f..9b42b7f 100644 --- a/Public/Get-LMCachedAccount.ps1 +++ b/Public/Get-LMCachedAccount.ps1 @@ -41,20 +41,20 @@ Function Get-LMCachedAccount { Param ( [String]$CachedAccountName ) - If($CachedAccountName){ + If ($CachedAccountName) { $CachedAccountSecrets = Get-SecretInfo -Vault Logic.Monitor -Name $CachedAccountName } - Else{ + Else { $CachedAccountSecrets = Get-SecretInfo -Vault Logic.Monitor } $CachedAccounts = @() - Foreach ($Secret in $CachedAccountSecrets){ + Foreach ($Secret in $CachedAccountSecrets) { $CachedAccounts += [PSCustomObject]@{ - CachedAccountName = $Secret.Name - Portal = $Secret.Metadata["Portal"] - Id = If(!$Secret.Metadata["Id"]){"N/A"}Else{$Secret.Metadata["Id"]} - Modified = $Secret.Metadata["Modified"] - Type = If(!$Secret.Metadata["Type"]){"LMv1"}Else{$Secret.Metadata["Type"]} + CachedAccountName = $Secret.Name + Portal = $Secret.Metadata["Portal"] + Id = If (!$Secret.Metadata["Id"]) { "N/A" }Else { $Secret.Metadata["Id"] } + Modified = $Secret.Metadata["Modified"] + Type = If (!$Secret.Metadata["Type"]) { "LMv1" }Else { $Secret.Metadata["Type"] } } } Return $CachedAccounts diff --git a/Public/Get-LMCollector.ps1 b/Public/Get-LMCollector.ps1 index c71db6f..26b4d52 100644 --- a/Public/Get-LMCollector.ps1 +++ b/Public/Get-LMCollector.ps1 @@ -45,7 +45,7 @@ Function Get-LMCollector { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMCollectorGroup.ps1 b/Public/Get-LMCollectorGroup.ps1 index caf0425..7e4be3c 100644 --- a/Public/Get-LMCollectorGroup.ps1 +++ b/Public/Get-LMCollectorGroup.ps1 @@ -43,7 +43,7 @@ Function Get-LMCollectorGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMCollectorInstaller.ps1 b/Public/Get-LMCollectorInstaller.ps1 index 09a57b6..2394dba 100644 --- a/Public/Get-LMCollectorInstaller.ps1 +++ b/Public/Get-LMCollectorInstaller.ps1 @@ -43,7 +43,7 @@ Function Get-LMCollectorInstaller { [Parameter(Mandatory, ParameterSetName = "Name")] [string]$Name, - [ValidateSet("nano", "small", "medium", "large", "extra_large","double_extra_large")] + [ValidateSet("nano", "small", "medium", "large", "extra_large", "double_extra_large")] [string]$Size = "medium", [ValidateSet("Win64", "Linux64")] @@ -84,7 +84,7 @@ Function Get-LMCollectorInstaller { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] -OutFile $DownloadPath Return $DownloadPath diff --git a/Public/Get-LMCollectorVersions.ps1 b/Public/Get-LMCollectorVersions.ps1 index e557eb1..76578b1 100644 --- a/Public/Get-LMCollectorVersions.ps1 +++ b/Public/Get-LMCollectorVersions.ps1 @@ -46,7 +46,7 @@ Function Get-LMCollectorVersions { [Parameter(ParameterSetName = 'Top')] [Switch]$TopVersions, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMConfigSource.ps1 b/Public/Get-LMConfigSource.ps1 index 6599ffc..2aa8380 100644 --- a/Public/Get-LMConfigSource.ps1 +++ b/Public/Get-LMConfigSource.ps1 @@ -45,7 +45,7 @@ Function Get-LMConfigSource { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDashboard.ps1 b/Public/Get-LMDashboard.ps1 index d3cf96e..de21952 100644 --- a/Public/Get-LMDashboard.ps1 +++ b/Public/Get-LMDashboard.ps1 @@ -75,7 +75,7 @@ Function Get-LMDashboard { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) diff --git a/Public/Get-LMDashboardGroup.ps1 b/Public/Get-LMDashboardGroup.ps1 index dbb0315..e21a247 100644 --- a/Public/Get-LMDashboardGroup.ps1 +++ b/Public/Get-LMDashboardGroup.ps1 @@ -17,7 +17,7 @@ Function Get-LMDashboardGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDashboardWidget.ps1 b/Public/Get-LMDashboardWidget.ps1 index daf8a4e..513e513 100644 --- a/Public/Get-LMDashboardWidget.ps1 +++ b/Public/Get-LMDashboardWidget.ps1 @@ -17,7 +17,7 @@ Function Get-LMDashboardWidget { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDatasource.ps1 b/Public/Get-LMDatasource.ps1 index e95fc26..2fbd66f 100644 --- a/Public/Get-LMDatasource.ps1 +++ b/Public/Get-LMDatasource.ps1 @@ -14,7 +14,7 @@ Function Get-LMDatasource { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDatasourceAssociatedDevices.ps1 b/Public/Get-LMDatasourceAssociatedDevices.ps1 index 204d653..09ffa66 100644 --- a/Public/Get-LMDatasourceAssociatedDevices.ps1 +++ b/Public/Get-LMDatasourceAssociatedDevices.ps1 @@ -13,7 +13,7 @@ Function Get-LMDatasourceAssociatedDevices { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDatasourceGraph.ps1 b/Public/Get-LMDatasourceGraph.ps1 index 4c5db26..5cd7767 100644 --- a/Public/Get-LMDatasourceGraph.ps1 +++ b/Public/Get-LMDatasourceGraph.ps1 @@ -2,37 +2,37 @@ Function Get-LMDatasourceGraph { [CmdletBinding()] Param ( - [Parameter(Mandatory,ParameterSetName = 'Id-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Id-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] [Int]$Id, - [Parameter(Mandatory,ParameterSetName = 'dsName')] - [Parameter(Mandatory,ParameterSetName = 'Id-dsName')] - [Parameter(Mandatory,ParameterSetName = 'Name-dsName')] - [Parameter(Mandatory,ParameterSetName = 'Filter-dsName')] + [Parameter(Mandatory, ParameterSetName = 'dsName')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsName')] [String]$DataSourceName, - [Parameter(Mandatory,ParameterSetName = 'dsId')] - [Parameter(Mandatory,ParameterSetName = 'Id-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Name-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Filter-dsId')] + [Parameter(Mandatory, ParameterSetName = 'dsId')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsId')] [String]$DataSourceId, - [Parameter(Mandatory,ParameterSetName = 'Name-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Name-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [String]$Name, - [Parameter(Mandatory,ParameterSetName = 'Filter-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Filter-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsName')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($DataSourceName){ + If ($DataSourceName) { $LookupResult = (Get-LMDatasource -Name $DataSourceName).Id If (Test-LookupResult -Result $LookupResult -LookupString $DataSourceName) { Return diff --git a/Public/Get-LMDatasourceMetadata.ps1 b/Public/Get-LMDatasourceMetadata.ps1 index ad08d70..4dcd91f 100644 --- a/Public/Get-LMDatasourceMetadata.ps1 +++ b/Public/Get-LMDatasourceMetadata.ps1 @@ -11,7 +11,7 @@ Function Get-LMDatasourceMetadata { [Parameter(ParameterSetName = 'DisplayName')] [String]$DisplayName, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -41,29 +41,29 @@ Function Get-LMDatasourceMetadata { #Initalize vars $QueryParams = "" - #Build query params - $QueryParams = "?size=$BatchSize&offset=$Count&sort=+id" + #Build query params + $QueryParams = "?size=$BatchSize&offset=$Count&sort=+id" - Try { - $Headers = New-LMHeader -Auth $Script:LMAuth -Method "GET" -ResourcePath $ResourcePath - $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + $QueryParams + Try { + $Headers = New-LMHeader -Auth $Script:LMAuth -Method "GET" -ResourcePath $ResourcePath + $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + $QueryParams - Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request - $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] + #Issue request + $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] - Return $Response + Return $Response + } + Catch [Exception] { + $Proceed = Resolve-LMException -LMException $PSItem + If (!$Proceed) { + Return } - Catch [Exception] { - $Proceed = Resolve-LMException -LMException $PSItem - If (!$Proceed) { - Return - } - } + } Return $Results } Else { diff --git a/Public/Get-LMDatasourceOverviewGraph.ps1 b/Public/Get-LMDatasourceOverviewGraph.ps1 index 8cc8703..d23564c 100644 --- a/Public/Get-LMDatasourceOverviewGraph.ps1 +++ b/Public/Get-LMDatasourceOverviewGraph.ps1 @@ -2,37 +2,37 @@ Function Get-LMDatasourceOverviewGraph { [CmdletBinding()] Param ( - [Parameter(Mandatory,ParameterSetName = 'Id-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Id-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] [Int]$Id, - [Parameter(Mandatory,ParameterSetName = 'dsName')] - [Parameter(Mandatory,ParameterSetName = 'Id-dsName')] - [Parameter(Mandatory,ParameterSetName = 'Name-dsName')] - [Parameter(Mandatory,ParameterSetName = 'Filter-dsName')] + [Parameter(Mandatory, ParameterSetName = 'dsName')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsName')] [String]$DataSourceName, - [Parameter(Mandatory,ParameterSetName = 'dsId')] - [Parameter(Mandatory,ParameterSetName = 'Id-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Name-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Filter-dsId')] + [Parameter(Mandatory, ParameterSetName = 'dsId')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsId')] [String]$DataSourceId, - [Parameter(Mandatory,ParameterSetName = 'Name-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Name-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [String]$Name, - [Parameter(Mandatory,ParameterSetName = 'Filter-dsId')] - [Parameter(Mandatory,ParameterSetName = 'Filter-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Filter-dsName')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($DataSourceName){ + If ($DataSourceName) { $LookupResult = (Get-LMDatasource -Name $DataSourceName).Id If (Test-LookupResult -Result $LookupResult -LookupString $DataSourceName) { Return diff --git a/Public/Get-LMDatasourceUpdateHistory.ps1 b/Public/Get-LMDatasourceUpdateHistory.ps1 index 5ffeec9..2ade8bf 100644 --- a/Public/Get-LMDatasourceUpdateHistory.ps1 +++ b/Public/Get-LMDatasourceUpdateHistory.ps1 @@ -13,7 +13,7 @@ Function Get-LMDatasourceUpdateHistory { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDevice.ps1 b/Public/Get-LMDevice.ps1 index 96a14f5..ab0e089 100644 --- a/Public/Get-LMDevice.ps1 +++ b/Public/Get-LMDevice.ps1 @@ -73,17 +73,17 @@ Function Get-LMDevice { [Parameter(ParameterSetName = 'Delta')] [String]$DeltaId, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { #Build header and uri - If($Delta -or $DeltaId){ + If ($Delta -or $DeltaId) { $ResourcePath = "/device/devices/delta" } - Else{ + Else { $ResourcePath = "/device/devices" } @@ -110,7 +110,7 @@ Function Get-LMDevice { $QueryParams = "?filter=$ValidFilter&size=$BatchSize&offset=$Count&sort=+id" } } - If($Delta -and $DeltaIdResponse){ + If ($Delta -and $DeltaIdResponse) { $QueryParams = $QueryParams + "&deltaId=$DeltaIdResponse" } Try { @@ -125,7 +125,7 @@ Function Get-LMDevice { $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] #Store delta id if delta switch is present - If($Response.deltaId -and !$DeltaIdResponse){ + If ($Response.deltaId -and !$DeltaIdResponse) { $DeltaIdResponse = $Response.deltaId Write-LMHost "[INFO]: Delta switch detected, for further queries you can use deltaId: $DeltaIdResponse to perform additional delta requests. This variable can be accessed by referencing the `$LMDeltaId " -ForegroundColor Yellow Set-Variable -Name "LMDeltaId" -Value $DeltaIdResponse -Scope global diff --git a/Public/Get-LMDeviceAlertSettings.ps1 b/Public/Get-LMDeviceAlertSettings.ps1 index de37483..bb73acd 100644 --- a/Public/Get-LMDeviceAlertSettings.ps1 +++ b/Public/Get-LMDeviceAlertSettings.ps1 @@ -10,11 +10,11 @@ Function Get-LMDeviceAlertSettings { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -86,5 +86,5 @@ Function Get-LMDeviceAlertSettings { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Get-LMDeviceAlerts.ps1 b/Public/Get-LMDeviceAlerts.ps1 index c660426..2ab282c 100644 --- a/Public/Get-LMDeviceAlerts.ps1 +++ b/Public/Get-LMDeviceAlerts.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceAlerts { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceConfigSourceData.ps1 b/Public/Get-LMDeviceConfigSourceData.ps1 index 305b437..95d88bf 100644 --- a/Public/Get-LMDeviceConfigSourceData.ps1 +++ b/Public/Get-LMDeviceConfigSourceData.ps1 @@ -35,12 +35,12 @@ Function Get-LMDeviceConfigSourceData { $Done = $false $Results = @() - Switch($ConfigType){ - "Delta" {$ConfigField = "!config"} - "Full" {$ConfigField = "!deltaConfig"} + Switch ($ConfigType) { + "Delta" { $ConfigField = "!config" } + "Full" { $ConfigField = "!deltaConfig" } } - If($LatestConfigOnly){ + If ($LatestConfigOnly) { $BatchSize = 1 $SortParam = "&sort=-pollTimestamp" } @@ -48,11 +48,11 @@ Function Get-LMDeviceConfigSourceData { #Loop through requests While (!$Done) { #Build query params - If($ConfigId){ + If ($ConfigId) { $ResourcePath = $ResourcePath + "/$ConfigId" $QueryParams = "?deviceId=$Id&deviceDataSourceId=$HdsId&instanceId=$HdsInsId&fields=$ConfigField" } - Else{ + Else { $QueryParams = "?size=$BatchSize&offset=$Count&fields=$ConfigField$SortParam" } @@ -72,7 +72,7 @@ Function Get-LMDeviceConfigSourceData { $Done = $true Return $Response } - ElseIf($LatestConfigOnly){ + ElseIf ($LatestConfigOnly) { Return $Response.Items } #Check result size and if needed loop again diff --git a/Public/Get-LMDeviceData.ps1 b/Public/Get-LMDeviceData.ps1 index 7d488a0..d025eef 100644 --- a/Public/Get-LMDeviceData.ps1 +++ b/Public/Get-LMDeviceData.ps1 @@ -44,7 +44,7 @@ Function Get-LMDeviceData { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) @@ -85,7 +85,7 @@ Function Get-LMDeviceData { #Lookup InstanceId If ($InstanceName) { - $LookupResult = (Get-LMDeviceDatasourceInstance -DeviceId $DeviceId -DatasourceId $DatasourceId | Where-Object { $_.displayName -eq $InstanceName -or $_.name -like "*$InstanceName" -or $_.name -eq "$InstanceName"}).Id + $LookupResult = (Get-LMDeviceDatasourceInstance -DeviceId $DeviceId -DatasourceId $DatasourceId | Where-Object { $_.displayName -eq $InstanceName -or $_.name -like "*$InstanceName" -or $_.name -eq "$InstanceName" }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } @@ -114,7 +114,7 @@ Function Get-LMDeviceData { } #Add time range filter if provided data ranges - If($StartDate -and $EndDate){ + If ($StartDate -and $EndDate) { $QueryParams = $QueryParams + "&start=$StartDate&end=$EndDate" } @@ -151,22 +151,22 @@ Function Get-LMDeviceData { } } #Convert results into readable format for consumption - If($Response){ + If ($Response) { $DatapointResults = @($null) * ($Response.values | Measure-Object).Count - for ($v = 0 ; $v -lt ($Response.values | Measure-Object).Count ; $v++){ - $DatapointResults[$v] = [PSCustomObject]@{} - $DatapointResults[$v] | Add-Member -MemberType NoteProperty -Name "TimestampEpoch" -Value $Response.time[$v] + for ($v = 0 ; $v -lt ($Response.values | Measure-Object).Count ; $v++) { + $DatapointResults[$v] = [PSCustomObject]@{} + $DatapointResults[$v] | Add-Member -MemberType NoteProperty -Name "TimestampEpoch" -Value $Response.time[$v] - $TimestampConverted = (([System.DateTimeOffset]::FromUnixTimeMilliseconds($Response.time[$v])).DateTime).ToString() - $DatapointResults[$v] | Add-Member -MemberType NoteProperty -Name "TimestampUTC" -Value $TimestampConverted + $TimestampConverted = (([System.DateTimeOffset]::FromUnixTimeMilliseconds($Response.time[$v])).DateTime).ToString() + $DatapointResults[$v] | Add-Member -MemberType NoteProperty -Name "TimestampUTC" -Value $TimestampConverted - for ($dp = 0 ; $dp -lt ($Response.dataPoints | Measure-Object).Count; $dp++){ + for ($dp = 0 ; $dp -lt ($Response.dataPoints | Measure-Object).Count; $dp++) { $DatapointResults[$v] | Add-Member -MemberType NoteProperty -Name $Response.dataPoints[$dp] -Value $Response.values[$v][$dp] } } Return $DatapointResults } - Else{ + Else { Return } diff --git a/Public/Get-LMDeviceDataSourceList.ps1 b/Public/Get-LMDeviceDataSourceList.ps1 index 32451b4..447f55d 100644 --- a/Public/Get-LMDeviceDataSourceList.ps1 +++ b/Public/Get-LMDeviceDataSourceList.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceDatasourceList { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceDatasourceInstance.ps1 b/Public/Get-LMDeviceDatasourceInstance.ps1 index cda63e5..1ff9ebf 100644 --- a/Public/Get-LMDeviceDatasourceInstance.ps1 +++ b/Public/Get-LMDeviceDatasourceInstance.ps1 @@ -22,7 +22,7 @@ Function Get-LMDeviceDatasourceInstance { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) diff --git a/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 b/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 index 79def1c..306e7cf 100644 --- a/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 @@ -23,7 +23,7 @@ Function Get-LMDeviceDatasourceInstanceAlertSetting { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) @@ -49,14 +49,14 @@ Function Get-LMDeviceDatasourceInstanceAlertSetting { } #Lookup HdsiId If ($DatasourceName) { - $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName" }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } $HdsiId = $LookupResult } - Else{ - $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id + Else { + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName" }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } diff --git a/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 b/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 index bc0077b..d6a422c 100644 --- a/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 @@ -26,7 +26,7 @@ Function Get-LMDeviceDatasourceInstanceGroup { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) diff --git a/Public/Get-LMDeviceEventSourceList.ps1 b/Public/Get-LMDeviceEventSourceList.ps1 index 0b5a2bc..6fe8d5c 100644 --- a/Public/Get-LMDeviceEventSourceList.ps1 +++ b/Public/Get-LMDeviceEventSourceList.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceEventSourceList { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroup.ps1 b/Public/Get-LMDeviceGroup.ps1 index 9f0ecef..39b14e1 100644 --- a/Public/Get-LMDeviceGroup.ps1 +++ b/Public/Get-LMDeviceGroup.ps1 @@ -41,7 +41,7 @@ Function Get-LMDeviceGroup { [CmdletBinding(DefaultParameterSetName = 'All')] Param ( - [Parameter(ParameterSetName = 'Id',ValueFromPipeline)] + [Parameter(ParameterSetName = 'Id', ValueFromPipeline)] [Int]$Id, [Parameter(ParameterSetName = 'Name')] @@ -50,7 +50,7 @@ Function Get-LMDeviceGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -120,5 +120,5 @@ Function Get-LMDeviceGroup { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Get-LMDeviceGroupAlerts.ps1 b/Public/Get-LMDeviceGroupAlerts.ps1 index b25501a..0634c9e 100644 --- a/Public/Get-LMDeviceGroupAlerts.ps1 +++ b/Public/Get-LMDeviceGroupAlerts.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceGroupAlerts { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroupDatasourceAlertSetting.ps1 b/Public/Get-LMDeviceGroupDatasourceAlertSetting.ps1 index 7a83d55..e1a6a2d 100644 --- a/Public/Get-LMDeviceGroupDatasourceAlertSetting.ps1 +++ b/Public/Get-LMDeviceGroupDatasourceAlertSetting.ps1 @@ -21,7 +21,7 @@ Function Get-LMDeviceGroupDatasourceAlertSetting { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroupDatasourceList.ps1 b/Public/Get-LMDeviceGroupDatasourceList.ps1 index 09d1704..daba80b 100644 --- a/Public/Get-LMDeviceGroupDatasourceList.ps1 +++ b/Public/Get-LMDeviceGroupDatasourceList.ps1 @@ -11,7 +11,7 @@ Function Get-LMDeviceGroupDatasourceList { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroupDevices.ps1 b/Public/Get-LMDeviceGroupDevices.ps1 index fd00e8e..d250e80 100644 --- a/Public/Get-LMDeviceGroupDevices.ps1 +++ b/Public/Get-LMDeviceGroupDevices.ps1 @@ -12,7 +12,7 @@ Function Get-LMDeviceGroupDevices { [Boolean]$IncludeSubGroups = $false, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -65,7 +65,7 @@ Function Get-LMDeviceGroupDevices { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] #Stop looping if single device, no need to continue @@ -92,7 +92,7 @@ Function Get-LMDeviceGroupDevices { } #Dedupe results } - If($Results){ + If ($Results) { $Results = ($Results | Sort-Object -Property Id -Unique) } Return (Add-ObjectTypeInfo -InputObject $Results -TypeName "LogicMonitor.Device" ) diff --git a/Public/Get-LMDeviceGroupGroups.ps1 b/Public/Get-LMDeviceGroupGroups.ps1 index 9f1fb76..07f2543 100644 --- a/Public/Get-LMDeviceGroupGroups.ps1 +++ b/Public/Get-LMDeviceGroupGroups.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceGroupGroups { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroupProperty.ps1 b/Public/Get-LMDeviceGroupProperty.ps1 index 8f42cf5..2a29b22 100644 --- a/Public/Get-LMDeviceGroupProperty.ps1 +++ b/Public/Get-LMDeviceGroupProperty.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceGroupProperty { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroupSDT.ps1 b/Public/Get-LMDeviceGroupSDT.ps1 index 47c5074..2a37519 100644 --- a/Public/Get-LMDeviceGroupSDT.ps1 +++ b/Public/Get-LMDeviceGroupSDT.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceGroupSDT { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceGroupSDTHistory.ps1 b/Public/Get-LMDeviceGroupSDTHistory.ps1 index a5143d8..cfeb464 100644 --- a/Public/Get-LMDeviceGroupSDTHistory.ps1 +++ b/Public/Get-LMDeviceGroupSDTHistory.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceGroupSDTHistory { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceInstanceData.ps1 b/Public/Get-LMDeviceInstanceData.ps1 index f47a787..8d0d331 100644 --- a/Public/Get-LMDeviceInstanceData.ps1 +++ b/Public/Get-LMDeviceInstanceData.ps1 @@ -56,7 +56,7 @@ Function Get-LMDeviceInstanceData { #Convert to epoch, if not set use defaults If (!$StartDate) { - [int]$StartDate = ([DateTimeOffset]$(Get-Date).AddHours(-24)).ToUnixTimeSeconds() + [int]$StartDate = ([DateTimeOffset]$(Get-Date).AddHours(-24)).ToUnixTimeSeconds() } Else { [int]$StartDate = ([DateTimeOffset]$($StartDate)).ToUnixTimeSeconds() diff --git a/Public/Get-LMDeviceInstanceList.ps1 b/Public/Get-LMDeviceInstanceList.ps1 index b115db7..0ee646e 100644 --- a/Public/Get-LMDeviceInstanceList.ps1 +++ b/Public/Get-LMDeviceInstanceList.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceInstanceList { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000, [Boolean]$CountOnly diff --git a/Public/Get-LMDeviceNetflowEndpoints.ps1 b/Public/Get-LMDeviceNetflowEndpoints.ps1 index e13c456..45a99b4 100644 --- a/Public/Get-LMDeviceNetflowEndpoints.ps1 +++ b/Public/Get-LMDeviceNetflowEndpoints.ps1 @@ -14,7 +14,7 @@ Function Get-LMDeviceNetflowEndpoints { [Datetime]$EndDate, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceNetflowFlows.ps1 b/Public/Get-LMDeviceNetflowFlows.ps1 index 5832743..ecc6f8c 100644 --- a/Public/Get-LMDeviceNetflowFlows.ps1 +++ b/Public/Get-LMDeviceNetflowFlows.ps1 @@ -14,7 +14,7 @@ Function Get-LMDeviceNetflowFlows { [Datetime]$EndDate, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceNetflowPorts.ps1 b/Public/Get-LMDeviceNetflowPorts.ps1 index ec8579c..7b2a525 100644 --- a/Public/Get-LMDeviceNetflowPorts.ps1 +++ b/Public/Get-LMDeviceNetflowPorts.ps1 @@ -14,7 +14,7 @@ Function Get-LMDeviceNetflowPorts { [Datetime]$EndDate, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceProperty.ps1 b/Public/Get-LMDeviceProperty.ps1 index ff5f973..d17df5b 100644 --- a/Public/Get-LMDeviceProperty.ps1 +++ b/Public/Get-LMDeviceProperty.ps1 @@ -15,7 +15,7 @@ Function Get-LMDeviceProperty { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -42,10 +42,10 @@ Function Get-LMDeviceProperty { } #Build header and uri - If($PropertyName){ + If ($PropertyName) { $ResourcePath = "/device/devices/$Id/properties/$PropertyName" } - Else{ + Else { $ResourcePath = "/device/devices/$Id/properties" } diff --git a/Public/Get-LMDeviceSDT.ps1 b/Public/Get-LMDeviceSDT.ps1 index 6ac6ba5..150cc30 100644 --- a/Public/Get-LMDeviceSDT.ps1 +++ b/Public/Get-LMDeviceSDT.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceSDT { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMDeviceSDTHistory.ps1 b/Public/Get-LMDeviceSDTHistory.ps1 index 49c1efb..f59408d 100644 --- a/Public/Get-LMDeviceSDTHistory.ps1 +++ b/Public/Get-LMDeviceSDTHistory.ps1 @@ -10,7 +10,7 @@ Function Get-LMDeviceSDTHistory { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMEscalationChain.ps1 b/Public/Get-LMEscalationChain.ps1 index 4cd511d..6daba70 100644 --- a/Public/Get-LMEscalationChain.ps1 +++ b/Public/Get-LMEscalationChain.ps1 @@ -11,7 +11,7 @@ Function Get-LMEscalationChain { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMEventSource.ps1 b/Public/Get-LMEventSource.ps1 index 5cd3b51..0c9b154 100644 --- a/Public/Get-LMEventSource.ps1 +++ b/Public/Get-LMEventSource.ps1 @@ -11,7 +11,7 @@ Function Get-LMEventSource { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMIntegrationLogs.ps1 b/Public/Get-LMIntegrationLogs.ps1 index 3848d2e..57a7ca0 100644 --- a/Public/Get-LMIntegrationLogs.ps1 +++ b/Public/Get-LMIntegrationLogs.ps1 @@ -17,7 +17,7 @@ Function Get-LMIntegrationLogs { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds @@ -35,7 +35,7 @@ Function Get-LMIntegrationLogs { #Convert to epoch, if not set use defaults If (!$StartDate) { - If($PSCmdlet.ParameterSetName -ne "Id"){ + If ($PSCmdlet.ParameterSetName -ne "Id") { Write-LMHost "[WARN]: No start date specified, defaulting to last 30 days" -ForegroundColor Yellow } [int]$StartDate = ([DateTimeOffset]$(Get-Date).AddDays(-30)).ToUnixTimeSeconds() diff --git a/Public/Get-LMNetscan.ps1 b/Public/Get-LMNetscan.ps1 index fd5b24b..50e0884 100644 --- a/Public/Get-LMNetscan.ps1 +++ b/Public/Get-LMNetscan.ps1 @@ -11,7 +11,7 @@ Function Get-LMNetscan { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMNetscanExecution.ps1 b/Public/Get-LMNetscanExecution.ps1 index 9477f55..ad81645 100644 --- a/Public/Get-LMNetscanExecution.ps1 +++ b/Public/Get-LMNetscanExecution.ps1 @@ -2,15 +2,15 @@ Function Get-LMNetscanExecution { [CmdletBinding(DefaultParameterSetName = 'Id')] Param ( - [Parameter(Mandatory,ParameterSetName = 'Id')] + [Parameter(Mandatory, ParameterSetName = 'Id')] [Int]$Id, - [Parameter(Mandatory,ParameterSetName = 'Name')] + [Parameter(Mandatory, ParameterSetName = 'Name')] [String]$Name, [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMNetscanExecutionDevices.ps1 b/Public/Get-LMNetscanExecutionDevices.ps1 index 08b912d..4939e69 100644 --- a/Public/Get-LMNetscanExecutionDevices.ps1 +++ b/Public/Get-LMNetscanExecutionDevices.ps1 @@ -2,18 +2,18 @@ Function Get-LMNetscanExecutionDevices { [CmdletBinding(DefaultParameterSetName = 'Id')] Param ( - [Parameter(Mandatory,ParameterSetName = 'Id')] + [Parameter(Mandatory, ParameterSetName = 'Id')] [Int]$Id, - [Parameter(Mandatory,ParameterSetName = 'Id')] + [Parameter(Mandatory, ParameterSetName = 'Id')] [String]$NspId, - [Parameter(Mandatory,ParameterSetName = 'Name')] + [Parameter(Mandatory, ParameterSetName = 'Name')] [String]$NspName, [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMNetscanGroup.ps1 b/Public/Get-LMNetscanGroup.ps1 index 264f831..e80b085 100644 --- a/Public/Get-LMNetscanGroup.ps1 +++ b/Public/Get-LMNetscanGroup.ps1 @@ -11,7 +11,7 @@ Function Get-LMNetscanGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMOpsNote.ps1 b/Public/Get-LMOpsNote.ps1 index 10fa4b9..21044e3 100644 --- a/Public/Get-LMOpsNote.ps1 +++ b/Public/Get-LMOpsNote.ps1 @@ -11,7 +11,7 @@ Function Get-LMOpsNote { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMPortalInfo.ps1 b/Public/Get-LMPortalInfo.ps1 index c98e066..001f190 100644 --- a/Public/Get-LMPortalInfo.ps1 +++ b/Public/Get-LMPortalInfo.ps1 @@ -15,7 +15,7 @@ Function Get-LMPortalInfo { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] } Catch [Exception] { diff --git a/Public/Get-LMPropertySource.ps1 b/Public/Get-LMPropertySource.ps1 index 117a846..110ef98 100644 --- a/Public/Get-LMPropertySource.ps1 +++ b/Public/Get-LMPropertySource.ps1 @@ -11,7 +11,7 @@ Function Get-LMPropertySource { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMRecipientGroup.ps1 b/Public/Get-LMRecipientGroup.ps1 index 1294de1..ad73fbd 100644 --- a/Public/Get-LMRecipientGroup.ps1 +++ b/Public/Get-LMRecipientGroup.ps1 @@ -11,7 +11,7 @@ Function Get-LMRecipientGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMReport.ps1 b/Public/Get-LMReport.ps1 index daec870..95fa46b 100644 --- a/Public/Get-LMReport.ps1 +++ b/Public/Get-LMReport.ps1 @@ -11,7 +11,7 @@ Function Get-LMReport { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMReportGroup.ps1 b/Public/Get-LMReportGroup.ps1 index 47317a6..4cfd037 100644 --- a/Public/Get-LMReportGroup.ps1 +++ b/Public/Get-LMReportGroup.ps1 @@ -11,7 +11,7 @@ Function Get-LMReportGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMRepositoryLogicModules.ps1 b/Public/Get-LMRepositoryLogicModules.ps1 index 3d80445..e8c3fdd 100644 --- a/Public/Get-LMRepositoryLogicModules.ps1 +++ b/Public/Get-LMRepositoryLogicModules.ps1 @@ -32,7 +32,7 @@ Function Get-LMRepositoryLogicModules { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data $Results = $Response.Items } diff --git a/Public/Get-LMRole.ps1 b/Public/Get-LMRole.ps1 index d93c6b8..94e1631 100644 --- a/Public/Get-LMRole.ps1 +++ b/Public/Get-LMRole.ps1 @@ -11,7 +11,7 @@ Function Get-LMRole { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMSDT.ps1 b/Public/Get-LMSDT.ps1 index c6111d0..9374754 100644 --- a/Public/Get-LMSDT.ps1 +++ b/Public/Get-LMSDT.ps1 @@ -11,7 +11,7 @@ Function Get-LMSDT { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMTopologyMap.ps1 b/Public/Get-LMTopologyMap.ps1 index ac59161..0d91af0 100644 --- a/Public/Get-LMTopologyMap.ps1 +++ b/Public/Get-LMTopologyMap.ps1 @@ -11,7 +11,7 @@ Function Get-LMTopologyMap { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMTopologySource.ps1 b/Public/Get-LMTopologySource.ps1 index 46cc42f..69a0bbc 100644 --- a/Public/Get-LMTopologySource.ps1 +++ b/Public/Get-LMTopologySource.ps1 @@ -11,7 +11,7 @@ Function Get-LMTopologySource { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMUnmonitoredDevice.ps1 b/Public/Get-LMUnmonitoredDevice.ps1 index b83d932..ba229c4 100644 --- a/Public/Get-LMUnmonitoredDevice.ps1 +++ b/Public/Get-LMUnmonitoredDevice.ps1 @@ -5,7 +5,7 @@ Function Get-LMUnmonitoredDevice { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMUsageMetrics.ps1 b/Public/Get-LMUsageMetrics.ps1 index dc6cab0..a3372d1 100644 --- a/Public/Get-LMUsageMetrics.ps1 +++ b/Public/Get-LMUsageMetrics.ps1 @@ -16,7 +16,7 @@ Function Get-LMUsageMetrics { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] Return $Response diff --git a/Public/Get-LMUser.ps1 b/Public/Get-LMUser.ps1 index 099a64f..e0def4d 100644 --- a/Public/Get-LMUser.ps1 +++ b/Public/Get-LMUser.ps1 @@ -11,7 +11,7 @@ Function Get-LMUser { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMUserGroup.ps1 b/Public/Get-LMUserGroup.ps1 index 830dd80..a5dccac 100644 --- a/Public/Get-LMUserGroup.ps1 +++ b/Public/Get-LMUserGroup.ps1 @@ -11,7 +11,7 @@ Function Get-LMUserGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsite.ps1 b/Public/Get-LMWebsite.ps1 index f70b88d..58bcf63 100644 --- a/Public/Get-LMWebsite.ps1 +++ b/Public/Get-LMWebsite.ps1 @@ -57,7 +57,7 @@ Function Get-LMWebsite { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteAlerts.ps1 b/Public/Get-LMWebsiteAlerts.ps1 index d11c8bf..8f261f7 100644 --- a/Public/Get-LMWebsiteAlerts.ps1 +++ b/Public/Get-LMWebsiteAlerts.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteAlerts { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteCheckpoint.ps1 b/Public/Get-LMWebsiteCheckpoint.ps1 index e6f2eed..63d2cb7 100644 --- a/Public/Get-LMWebsiteCheckpoint.ps1 +++ b/Public/Get-LMWebsiteCheckpoint.ps1 @@ -6,7 +6,7 @@ Function Get-LMWebsiteCheckpoint { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteData.ps1 b/Public/Get-LMWebsiteData.ps1 index ef877c3..d92eb7d 100644 --- a/Public/Get-LMWebsiteData.ps1 +++ b/Public/Get-LMWebsiteData.ps1 @@ -61,7 +61,7 @@ Function Get-LMWebsiteData { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] Return $Response diff --git a/Public/Get-LMWebsiteGroup.ps1 b/Public/Get-LMWebsiteGroup.ps1 index a918147..89412bf 100644 --- a/Public/Get-LMWebsiteGroup.ps1 +++ b/Public/Get-LMWebsiteGroup.ps1 @@ -11,7 +11,7 @@ Function Get-LMWebsiteGroup { [Parameter(ParameterSetName = 'Filter')] [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteGroupAlerts.ps1 b/Public/Get-LMWebsiteGroupAlerts.ps1 index dc48ae6..88462e7 100644 --- a/Public/Get-LMWebsiteGroupAlerts.ps1 +++ b/Public/Get-LMWebsiteGroupAlerts.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteGroupAlerts { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteGroupSDT.ps1 b/Public/Get-LMWebsiteGroupSDT.ps1 index f587ad7..ffd4406 100644 --- a/Public/Get-LMWebsiteGroupSDT.ps1 +++ b/Public/Get-LMWebsiteGroupSDT.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteGroupSDT { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteGroupSDTHistory.ps1 b/Public/Get-LMWebsiteGroupSDTHistory.ps1 index 7ae6480..d0e262f 100644 --- a/Public/Get-LMWebsiteGroupSDTHistory.ps1 +++ b/Public/Get-LMWebsiteGroupSDTHistory.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteGroupSDTHistory { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteProperty.ps1 b/Public/Get-LMWebsiteProperty.ps1 index 830478c..cd6dcae 100644 --- a/Public/Get-LMWebsiteProperty.ps1 +++ b/Public/Get-LMWebsiteProperty.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteProperty { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteSDT.ps1 b/Public/Get-LMWebsiteSDT.ps1 index 9d06dde..b331c02 100644 --- a/Public/Get-LMWebsiteSDT.ps1 +++ b/Public/Get-LMWebsiteSDT.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteSDT { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Get-LMWebsiteSDTHistory.ps1 b/Public/Get-LMWebsiteSDTHistory.ps1 index 04b4757..2adabde 100644 --- a/Public/Get-LMWebsiteSDTHistory.ps1 +++ b/Public/Get-LMWebsiteSDTHistory.ps1 @@ -10,7 +10,7 @@ Function Get-LMWebsiteSDTHistory { [Object]$Filter, - [ValidateRange(1,1000)] + [ValidateRange(1, 1000)] [Int]$BatchSize = 1000 ) #Check if we are logged in and have valid api creds diff --git a/Public/Import-LMDashboard.ps1 b/Public/Import-LMDashboard.ps1 index 05bab7a..eb33819 100644 --- a/Public/Import-LMDashboard.ps1 +++ b/Public/Import-LMDashboard.ps1 @@ -83,29 +83,29 @@ Function Import-LMDashboard { $Results = @() $DashboardList = @() - If($ParentGroupName){ + If ($ParentGroupName) { $ParentGroupId = (Get-LMDashboardGroup -Name $ParentGroupName | Select-Object -First 1 ).Id } - If($ParentGroupId){ + If ($ParentGroupId) { $ParentGroupName = (Get-LMDashboardGroup -Id $ParentGroupId | Select-Object -First 1 ).Name } - If($FilePath){ - If((Get-Item $FilePath) -is [System.IO.DirectoryInfo]){ + If ($FilePath) { + If ((Get-Item $FilePath) -is [System.IO.DirectoryInfo]) { $FullPath = (Resolve-Path $FilePath).Path - $Files = Get-ChildItem $FullPath -Recurse | Where-Object {([IO.Path]::GetExtension($_.Name) -eq '.json')} - Foreach($F in $Files){ + $Files = Get-ChildItem $FullPath -Recurse | Where-Object { ([IO.Path]::GetExtension($_.Name) -eq '.json') } + Foreach ($F in $Files) { #Convert from json into object $RawFile = Get-Content $F.FullName -Raw | ConvertFrom-Json $DashboardList += @{ - file = $RawFile - path = $($F.DirectoryName -split $FullPath)[1] - parentid = $ParentGroupId + file = $RawFile + path = $($F.DirectoryName -split $FullPath)[1] + parentid = $ParentGroupId parentname = $ParentGroupName } } } - Else{ + Else { If (!(Test-Path -Path $FilePath) -and (!([IO.Path]::GetExtension($FilePath) -eq '.json'))) { Write-Error "File not found or is not a valid json file, check file path and try again" Return @@ -114,39 +114,39 @@ Function Import-LMDashboard { #Convert from json into object $RawFile = Get-Content $FilePath -Raw | ConvertFrom-Json $DashboardList += @{ - file = $RawFile - path = "" - parentid = $ParentGroupId + file = $RawFile + path = "" + parentid = $ParentGroupId parentname = $ParentGroupName } } } - If($File){ + If ($File) { $DashboardList += @{ - file = $File | ConvertFrom-Json - path = "" - parentid = $ParentGroupId + file = $File | ConvertFrom-Json + path = "" + parentid = $ParentGroupId parentname = $ParentGroupName } } - If($GithubUserRepo){ + If ($GithubUserRepo) { $Headers = @{} - If($GithubAccessToken){ - $Headers = @{"Authorization"="token $GithubAccessToken"} + If ($GithubAccessToken) { + $Headers = @{"Authorization" = "token $GithubAccessToken" } } $Uri = "https://api.github.com/repos/$GithubUserRepo/git/trees/master?recursive=1" - $RepoData = (Invoke-RestMethod -Uri $Uri -Headers $Headers[0] -WebSession $Headers[1]).tree | Where-Object {$_.Path -like "*.json" -and $_.Path -notlike "Packages/LogicMonitor_Dashboards*"} | Select-Object path,url - If($RepoData){ + $RepoData = (Invoke-RestMethod -Uri $Uri -Headers $Headers[0] -WebSession $Headers[1]).tree | Where-Object { $_.Path -like "*.json" -and $_.Path -notlike "Packages/LogicMonitor_Dashboards*" } | Select-Object path, url + If ($RepoData) { $TotalItems = ($RepoData | Measure-Object).Count Write-LMHost "[INFO]: Found $TotalItems JSON files from Github repo ($GithubUserRepo)" - Foreach ($Item in $RepoData){ + Foreach ($Item in $RepoData) { $EncodedDash = (Invoke-RestMethod -Uri $Item.url -Headers $Headers[0] -WebSession $Headers[1]).content $DashboardList += @{ - file = [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($EncodedDash)) | ConvertFrom-Json - path = [System.IO.Path]::GetDirectoryName($Item.path) - parentid = $ParentGroupId + file = [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($EncodedDash)) | ConvertFrom-Json + path = [System.IO.Path]::GetDirectoryName($Item.path) + parentid = $ParentGroupId parentname = $ParentGroupName } @@ -155,39 +155,39 @@ Function Import-LMDashboard { } } - If($ReplaceAPITokensOnImport -and !($APIToken)){ + If ($ReplaceAPITokensOnImport -and !($APIToken)) { $DashboardAPIRoleName = "lm-dynamic-dashboards" $DashboardAPIUserName = "lm_dynamic_dashboards" $DashboardAPIRole = Get-LMRole -Name $DashboardAPIRoleName $DashboardAPIUser = Get-LMUser -Name $DashboardAPIUserName - If(!$DashboardAPIRole){ + If (!$DashboardAPIRole) { $DashboardAPIRole = New-LMRole -Name $DashboardAPIRoleName -ResourcePermission view -DashboardsPermission manage -Description "Auto provisioned for use with dynamic dashboards" Write-LMHost "[INFO]: Successfully generated required API role ($DashboardAPIRoleName) for dynamic dashboards" } - If(!$DashboardAPIUser){ + If (!$DashboardAPIUser) { $DashboardAPIUser = New-LMAPIUser -Username "$DashboardAPIUserName" -note "Auto provisioned for use with dynamic dashboards" -RoleNames @($DashboardAPIRoleName) Write-LMHost "[INFO]: Successfully generated required API user ($DashboardAPIUserName) for dynamic dashboards" } - If($DashboardAPIRole -and $DashboardAPIUser){ + If ($DashboardAPIRole -and $DashboardAPIUser) { $APIToken = New-LMAPIToken -Username $DashboardAPIUserName -Note "Auto provisioned for use with dynamic dashboards" - If($APIToken){ + If ($APIToken) { Write-LMHost "[INFO]: Successfully generated required API token for dynamic dashboards for user: $DashboardAPIUserName" } } - Else{ + Else { Write-LMHost "[WARN]: Unable to generate required API token for dynamic dashboards, manually update the required tokens to use dynamic dashboards" -ForegroundColor Yellow } } - Foreach($Dashboard in $DashboardList){ + Foreach ($Dashboard in $DashboardList) { #Swap apiKeys for dynamic dashboards - If($ReplaceAPITokensOnImport){ - If($APIToken){ - If($Dashboard.file.widgetTokens.name -contains "apiKey"){ - $KeyIndex = $Dashboard.file.widgetTokens.name.toLower().IndexOf("apikey") - $Dashboard.file.widgetTokens[$KeyIndex].value = $APIToken.accessKey + If ($ReplaceAPITokensOnImport) { + If ($APIToken) { + If ($Dashboard.file.widgetTokens.name -contains "apiKey") { + $KeyIndex = $Dashboard.file.widgetTokens.name.toLower().IndexOf("apikey") + $Dashboard.file.widgetTokens[$KeyIndex].value = $APIToken.accessKey } - If($Dashboard.file.widgetTokens.name -contains "apiID"){ + If ($Dashboard.file.widgetTokens.name -contains "apiID") { $IdIndex = $Dashboard.file.widgetTokens.name.toLower().IndexOf("apiid") $Dashboard.file.widgetTokens[$IdIndex].value = $APIToken.accessId } @@ -195,32 +195,32 @@ Function Import-LMDashboard { } #Check if a path has been provided and check if folder exists in selected root folder, if not create - If($Dashboard.path){ - [Array]$SubFolders = $Dashboard.path -split "\\|/" | Where-Object {$_} + If ($Dashboard.path) { + [Array]$SubFolders = $Dashboard.path -split "\\|/" | Where-Object { $_ } - For($Index = 0; $Index -lt $($SubFolders | Measure-Object).Count; $Index++){ + For ($Index = 0; $Index -lt $($SubFolders | Measure-Object).Count; $Index++) { - If($Index -eq 0){ - $DashboardGroup = Get-LMDashboardGroup -ParentGroupId $ParentGroupId | Where-Object {$_.Name -eq $SubFolders[$Index]} + If ($Index -eq 0) { + $DashboardGroup = Get-LMDashboardGroup -ParentGroupId $ParentGroupId | Where-Object { $_.Name -eq $SubFolders[$Index] } - If(!$DashboardGroup){ + If (!$DashboardGroup) { Write-LMHost "[INFO]: Existing dashboard group not found for $($Subfolders[$Index]) creating new resource group under root group ($ParentGroupName)" $NewDashboardGroup = New-LMDashboardGroup -Name $SubFolders[$Index] -ParentGroupId $ParentGroupId $Dashboard.parentid = $NewDashboardGroup.id $Dashboard.parentname = $NewDashboardGroup.name } - Else{ + Else { $Dashboard.parentid = $DashboardGroup.id $Dashboard.parentname = $DashboardGroup.name } } - Else{ - $DashboardGroup = Get-LMDashboardGroup -Name $Subfolders[$Index] | Where-Object { $_.fullPath -like "$($Subfolders[0])*$($Subfolders[$Index])"} + Else { + $DashboardGroup = Get-LMDashboardGroup -Name $Subfolders[$Index] | Where-Object { $_.fullPath -like "$($Subfolders[0])*$($Subfolders[$Index])" } - If(!$DashboardGroup){ + If (!$DashboardGroup) { - $NewDashboardParentGroup = Get-LMDashboardGroup -Name $Subfolders[$Index-1] | Where-Object {$_.fullPath -like "$ParentGroupName*" -or $_.fullPath -eq $Subfolders[$Index-1]} + $NewDashboardParentGroup = Get-LMDashboardGroup -Name $Subfolders[$Index - 1] | Where-Object { $_.fullPath -like "$ParentGroupName*" -or $_.fullPath -eq $Subfolders[$Index - 1] } Write-LMHost "[INFO]: Existing dashboard group not found for $($Subfolders[$Index]) creating new resource group under group ($($NewDashboardParentGroup.Name))" $NewDashboardGroup = New-LMDashboardGroup -Name $SubFolders[$Index] -ParentGroupId $NewDashboardParentGroup.id @@ -228,7 +228,7 @@ Function Import-LMDashboard { $Dashboard.parentname = $NewDashboardGroup.name } - Else{ + Else { $Dashboard.parentid = $DashboardGroup.id $Dashboard.parentname = $DashboardGroup.name } @@ -238,14 +238,14 @@ Function Import-LMDashboard { #Construct our object for import $Data = @{ - description = $Dashboard.file.description - groupId = [int]$Dashboard.parentid - groupName = $Dashboard.parentname - name = $Dashboard.file.name - sharable = If($PrivateUserName){$False} Else{$True} - owner = $PrivateUserName - template = $Dashboard.file | Select-Object -ExcludeProperty group - widgetTokens = $Dashboard.file.widgetTokens + description = $Dashboard.file.description + groupId = [int]$Dashboard.parentid + groupName = $Dashboard.parentname + name = $Dashboard.file.name + sharable = If ($PrivateUserName) { $False } Else { $True } + owner = $PrivateUserName + template = $Dashboard.file | Select-Object -ExcludeProperty group + widgetTokens = $Dashboard.file.widgetTokens widgetsConfigVersion = $Dashboard.file.widgetsConfigVersion } @@ -260,7 +260,7 @@ Function Import-LMDashboard { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Write-Output "Successfully imported dashboard: $($Dashboard.file.name)" @@ -271,7 +271,7 @@ Function Import-LMDashboard { Write-Output "Failed to import dashboard: $($Dashboard.file.name)" $Proceed = Resolve-LMException -LMException $PSItem If (!$Proceed) { - # Return + # Return } } } diff --git a/Public/Import-LMExchangeModule.ps1 b/Public/Import-LMExchangeModule.ps1 index b6efa7f..e7267f7 100644 --- a/Public/Import-LMExchangeModule.ps1 +++ b/Public/Import-LMExchangeModule.ps1 @@ -28,7 +28,7 @@ Function Import-LMExchangeModule { $ResourcePath = "/exchange/integrations/import" #Construct payload - $Data = @{items = @()} + $Data = @{items = @() } $Data.items += [PSCustomObject]@{ id = $LMExchangeId } diff --git a/Public/Import-LMLogicModule.ps1 b/Public/Import-LMLogicModule.ps1 index f7bcf73..e2b2785 100644 --- a/Public/Import-LMLogicModule.ps1 +++ b/Public/Import-LMLogicModule.ps1 @@ -31,10 +31,10 @@ This function requires PowerShell version 6.1 or higher to run. Function Import-LMLogicModule { [CmdletBinding()] Param ( - [Parameter(Mandatory,ParameterSetName = 'FilePath')] + [Parameter(Mandatory, ParameterSetName = 'FilePath')] [String]$FilePath, - [Parameter(Mandatory,ParameterSetName = 'File')] + [Parameter(Mandatory, ParameterSetName = 'File')] [Object]$File, [ValidateSet("datasource", "propertyrules", "eventsource", "topologysource", "configsource")] @@ -49,7 +49,7 @@ Function Import-LMLogicModule { If ($Script:LMAuth.Valid) { #Get file content from path if not given file data directly - If($FilePath){ + If ($FilePath) { #Check for PS version 6.1 + If (($PSVersionTable.PSVersion.Major -le 5) -or ($PSVersionTable.PSVersion.Major -eq 6 -and $PSVersionTable.PSVersion.Minor -lt 1)) { @@ -76,7 +76,7 @@ Function Import-LMLogicModule { $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $File $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + $QueryParams - Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $FilePath + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $FilePath #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Form @{file = $File } diff --git a/Public/Import-LMRepositoryLogicModules.ps1 b/Public/Import-LMRepositoryLogicModules.ps1 index e3b59f7..0c3cd31 100644 --- a/Public/Import-LMRepositoryLogicModules.ps1 +++ b/Public/Import-LMRepositoryLogicModules.ps1 @@ -25,13 +25,13 @@ Function Import-LMRepositoryLogicModules { [ValidateSet("datasources", "propertyrules", "eventsources", "topologysources", "configsources")] [String]$Type, - [Parameter(Mandatory,ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('Name')] [String[]]$LogicModuleNames ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -73,5 +73,5 @@ Function Import-LMRepositoryLogicModules { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Invoke-LMActiveDiscovery.ps1 b/Public/Invoke-LMActiveDiscovery.ps1 index 0d77b36..6265d75 100644 --- a/Public/Invoke-LMActiveDiscovery.ps1 +++ b/Public/Invoke-LMActiveDiscovery.ps1 @@ -107,7 +107,7 @@ Function Invoke-LMActiveDiscovery { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] Write-Host "Scheduled Active Discovery task for device id: $device." diff --git a/Public/Invoke-LMCloudGroupNetScan.ps1 b/Public/Invoke-LMCloudGroupNetScan.ps1 index 3ea5ac2..e53276a 100644 --- a/Public/Invoke-LMCloudGroupNetScan.ps1 +++ b/Public/Invoke-LMCloudGroupNetScan.ps1 @@ -46,11 +46,11 @@ Function Invoke-LMCloudGroupNetScan { } $Id = $LookupResult } - Else{ + Else { $GroupInfo = Get-LMDeviceGroup -Id $Id } - If($GroupInfo.groupType -notlike "*AWS*" -and $GroupInfo.groupType -notlike "*Azure*" -and $GroupInfo.groupType -notlike "*GCP*"){ + If ($GroupInfo.groupType -notlike "*AWS*" -and $GroupInfo.groupType -notlike "*Azure*" -and $GroupInfo.groupType -notlike "*GCP*") { Write-Error "Specified group: $($GroupInfo.Name) is not of type AWs/Azure/GCP. Please ensure the specified group is a Cloud group and try again." } diff --git a/Public/Invoke-LMCollectorDebugCommand.ps1 b/Public/Invoke-LMCollectorDebugCommand.ps1 index d785a94..a04753e 100644 --- a/Public/Invoke-LMCollectorDebugCommand.ps1 +++ b/Public/Invoke-LMCollectorDebugCommand.ps1 @@ -81,8 +81,8 @@ Function Invoke-LMCollectorDebugCommand { Process { If ($Script:LMAuth.Valid) { -#Cannot indent or it breaks here-string format -$DefaultGroovy =@" + #Cannot indent or it breaks here-string format + $DefaultGroovy = @" !groovy import com.santaba.agent.collector3.CollectorDb; def hostProps = [:]; @@ -98,8 +98,8 @@ catch(Exception e) { $GroovyCommand "@ -#Cannot indent or it breaks here-string format -$DefaultPosh =@" + #Cannot indent or it breaks here-string format + $DefaultPosh = @" !posh $PoshCommand diff --git a/Public/New-LMAPIToken.ps1 b/Public/New-LMAPIToken.ps1 index 35bd69c..ddb4963 100644 --- a/Public/New-LMAPIToken.ps1 +++ b/Public/New-LMAPIToken.ps1 @@ -59,7 +59,7 @@ Function New-LMAPIToken { } #Build header and uri - If($Type -eq "Bearer"){ + If ($Type -eq "Bearer") { $Params = "?type=bearer" } @@ -78,7 +78,7 @@ Function New-LMAPIToken { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.APIToken" ) diff --git a/Public/New-LMAlertAck.ps1 b/Public/New-LMAlertAck.ps1 index 0f95a96..d49f41c 100644 --- a/Public/New-LMAlertAck.ps1 +++ b/Public/New-LMAlertAck.ps1 @@ -28,8 +28,8 @@ Function New-LMAlertAck { [Parameter(Mandatory)] [String]$Note ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -39,8 +39,8 @@ Function New-LMAlertAck { Try { $Data = @{ - alertIds = $Ids - ackComment = $Note + alertIds = $Ids + ackComment = $Note } $Data = ($Data | ConvertTo-Json) @@ -53,7 +53,7 @@ Function New-LMAlertAck { #Issue request $Response = Invoke-WebRequest -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data - If($Response.StatusCode -eq 200){ + If ($Response.StatusCode -eq 200) { Return "Successfully acknowledged alert id(s): $Ids" } } @@ -68,5 +68,5 @@ Function New-LMAlertAck { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/New-LMAlertEscalation.ps1 b/Public/New-LMAlertEscalation.ps1 index 91d5913..7fb75c2 100644 --- a/Public/New-LMAlertEscalation.ps1 +++ b/Public/New-LMAlertEscalation.ps1 @@ -20,8 +20,8 @@ Function New-LMAlertEscalation { [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [String]$Id ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -38,7 +38,7 @@ Function New-LMAlertEscalation { #Issue request $Response = Invoke-WebRequest -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] - If($Response.StatusCode -eq 200){ + If ($Response.StatusCode -eq 200) { Return "Successfully escalated alert id: $Id" } } @@ -53,5 +53,5 @@ Function New-LMAlertEscalation { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/New-LMAlertNote.ps1 b/Public/New-LMAlertNote.ps1 index 739b643..0f9271e 100644 --- a/Public/New-LMAlertNote.ps1 +++ b/Public/New-LMAlertNote.ps1 @@ -32,8 +32,8 @@ Function New-LMAlertNote { [Parameter(Mandatory)] [String]$Note ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -44,7 +44,7 @@ Function New-LMAlertNote { $Data = @{ alertIds = $Ids - note = $Note + note = $Note } $Data = ($Data | ConvertTo-Json) @@ -57,7 +57,7 @@ Function New-LMAlertNote { #Issue request $Response = Invoke-WebRequest -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data - If($Response.StatusCode -eq 200){ + If ($Response.StatusCode -eq 200) { Return "Successfully updated note for alert id(s): $Ids" } } @@ -72,5 +72,5 @@ Function New-LMAlertNote { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/New-LMAppliesToFunction.ps1 b/Public/New-LMAppliesToFunction.ps1 index 007f38a..e1403c2 100644 --- a/Public/New-LMAppliesToFunction.ps1 +++ b/Public/New-LMAppliesToFunction.ps1 @@ -41,9 +41,9 @@ Function New-LMAppliesToFunction { Try { $Data = @{ - name = $Name - description = $Description - code = $AppliesTo + name = $Name + description = $Description + code = $AppliesTo } $Data = ($Data | ConvertTo-Json) @@ -53,7 +53,7 @@ Function New-LMAppliesToFunction { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMCachedAccount.ps1 b/Public/New-LMCachedAccount.ps1 index 7887545..e975146 100644 --- a/Public/New-LMCachedAccount.ps1 +++ b/Public/New-LMCachedAccount.ps1 @@ -19,19 +19,19 @@ New-LMCachedAccount -AccessId xxxxxx -AccessKey xxxxxx -AccountName subdomain #> Function New-LMCachedAccount { - [CmdletBinding(DefaultParameterSetName="LMv1")] + [CmdletBinding(DefaultParameterSetName = "LMv1")] Param ( - [Parameter(Mandatory, ParameterSetName="LMv1")] + [Parameter(Mandatory, ParameterSetName = "LMv1")] [String]$AccessId, - [Parameter(Mandatory, ParameterSetName="LMv1")] + [Parameter(Mandatory, ParameterSetName = "LMv1")] [String]$AccessKey, - [Parameter(Mandatory, ParameterSetName="LMv1")] - [Parameter(Mandatory, ParameterSetName="Bearer")] + [Parameter(Mandatory, ParameterSetName = "LMv1")] + [Parameter(Mandatory, ParameterSetName = "Bearer")] [String]$AccountName, - [Parameter(Mandatory, ParameterSetName="Bearer")] + [Parameter(Mandatory, ParameterSetName = "Bearer")] [String]$BearerToken, [String]$CachedAccountName = $AccountName, @@ -44,7 +44,7 @@ Function New-LMCachedAccount { Write-Host "[INFO]: Existing vault Logic.Monitor already exists, skipping creation" } Catch { - If($_.Exception.Message -like "*There are currently no extension vaults registered*") { + If ($_.Exception.Message -like "*There are currently no extension vaults registered*") { Write-Host "[INFO]: Credential vault for cached accounts does not currently exist, creating credential vault: Logic.Monitor" Register-SecretVault -Name Logic.Monitor -ModuleName Microsoft.PowerShell.SecretStore Get-SecretStoreConfiguration | Out-Null @@ -53,29 +53,29 @@ Function New-LMCachedAccount { $CurrentDate = Get-Date #Convert to secure string - If($BearerToken){ + If ($BearerToken) { $Secret = $BearerToken | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString [Hashtable]$Metadata = @{ - Portal = [String]$AccountName - Id = "$($BearerToken.Substring(0,20))****" - Modified = [DateTime]$CurrentDate - Type = "Bearer" + Portal = [String]$AccountName + Id = "$($BearerToken.Substring(0,20))****" + Modified = [DateTime]$CurrentDate + Type = "Bearer" } } - Else{ + Else { $Secret = $AccessKey | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString [Hashtable]$Metadata = @{ - Portal = [String]$AccountName - Id = [String]$AccessId - Modified = [DateTime]$CurrentDate - Type = "LMv1" + Portal = [String]$AccountName + Id = [String]$AccessId + Modified = [DateTime]$CurrentDate + Type = "LMv1" } } - Try{ + Try { Set-Secret -Name $CachedAccountName -Secret $Secret -Vault Logic.Monitor -Metadata $Metadata -NoClobber:$(!$OverwriteExisting) Write-Host "[INFO]: Successfully created cached account ($CachedAccountName) secret for portal: $AccountName" } - Catch{ + Catch { Write-Error $_.Exception.Message } diff --git a/Public/New-LMCollectorGroup.ps1 b/Public/New-LMCollectorGroup.ps1 index 630a369..33262a0 100644 --- a/Public/New-LMCollectorGroup.ps1 +++ b/Public/New-LMCollectorGroup.ps1 @@ -63,11 +63,11 @@ Function New-LMCollectorGroup { Try { $Data = @{ - description = $Description - name = $Name - autoBalance = $AutoBalance - customProperties = $customProperties - autoBalanceInstanceCountThreshold = $AutoBalanceInstanceCountThreshold + description = $Description + name = $Name + autoBalance = $AutoBalance + customProperties = $customProperties + autoBalanceInstanceCountThreshold = $AutoBalanceInstanceCountThreshold } diff --git a/Public/New-LMDashboardGroup.ps1 b/Public/New-LMDashboardGroup.ps1 index e4492ec..c264ca7 100644 --- a/Public/New-LMDashboardGroup.ps1 +++ b/Public/New-LMDashboardGroup.ps1 @@ -79,10 +79,10 @@ Function New-LMDashboardGroup { Try { $Data = @{ - name = $Name - description = $Description - parentId = $ParentGroupId - widgetTokens = $WidgetTokensArray + name = $Name + description = $Description + parentId = $ParentGroupId + widgetTokens = $WidgetTokensArray } $Data = ($Data | ConvertTo-Json) @@ -92,7 +92,7 @@ Function New-LMDashboardGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDatasourceGraph.ps1 b/Public/New-LMDatasourceGraph.ps1 index 6d618a0..c3729f1 100644 --- a/Public/New-LMDatasourceGraph.ps1 +++ b/Public/New-LMDatasourceGraph.ps1 @@ -38,7 +38,7 @@ Function New-LMDatasourceGraph { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($DataSourceName){ + If ($DataSourceName) { $LookupResult = (Get-LMDatasource -Name $DataSourceName).Id If (Test-LookupResult -Result $LookupResult -LookupString $DataSourceName) { Return diff --git a/Public/New-LMDatasourceOverviewGraph.ps1 b/Public/New-LMDatasourceOverviewGraph.ps1 index 82c0961..e82a2ac 100644 --- a/Public/New-LMDatasourceOverviewGraph.ps1 +++ b/Public/New-LMDatasourceOverviewGraph.ps1 @@ -27,17 +27,17 @@ Function New-LMDatasourceOverviewGraph { [Parameter(Mandatory)] $RawObject, - [Parameter(Mandatory,ParameterSetName = 'dsId')] + [Parameter(Mandatory, ParameterSetName = 'dsId')] $DatasourceId, - [Parameter(Mandatory,ParameterSetName = 'dsName')] + [Parameter(Mandatory, ParameterSetName = 'dsName')] $DatasourceName ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($DataSourceName){ + If ($DataSourceName) { $LookupResult = (Get-LMDatasource -Name $DataSourceName).Id If (Test-LookupResult -Result $LookupResult -LookupString $DataSourceName) { Return @@ -56,7 +56,7 @@ Function New-LMDatasourceOverviewGraph { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.DatasourceGraph" ) diff --git a/Public/New-LMDevice.ps1 b/Public/New-LMDevice.ps1 index 4c1a2b4..5e33330 100644 --- a/Public/New-LMDevice.ps1 +++ b/Public/New-LMDevice.ps1 @@ -119,22 +119,22 @@ Function New-LMDevice { Try { $Data = @{ - name = $Name - displayName = $DisplayName - description = $Description - disableAlerting = $DisableAlerting - enableNetflow = $EnableNetFlow - customProperties = $customProperties - deviceType = $DeviceType - preferredCollectorId = $PreferredCollectorId - preferredCollectorGroupId = $PreferredCollectorGroupId + name = $Name + displayName = $DisplayName + description = $Description + disableAlerting = $DisableAlerting + enableNetflow = $EnableNetFlow + customProperties = $customProperties + deviceType = $DeviceType + preferredCollectorId = $PreferredCollectorId + preferredCollectorGroupId = $PreferredCollectorGroupId autoBalancedCollectorGroupId = $AutoBalancedCollectorGroupId - link = $Link - netflowCollectorGroupId = $NetflowCollectorGroupId - netflowCollectorId = $NetflowCollectorId - logCollectorGroupId = $LogCollectorGroupId - logCollectorId = $LogCollectorId - hostGroupIds = $HostGroupIds -join "," + link = $Link + netflowCollectorGroupId = $NetflowCollectorGroupId + netflowCollectorId = $NetflowCollectorId + logCollectorGroupId = $LogCollectorGroupId + logCollectorId = $LogCollectorId + hostGroupIds = $HostGroupIds -join "," } diff --git a/Public/New-LMDeviceDatasourceInstance.ps1 b/Public/New-LMDeviceDatasourceInstance.ps1 index 16c219c..100a677 100644 --- a/Public/New-LMDeviceDatasourceInstance.ps1 +++ b/Public/New-LMDeviceDatasourceInstance.ps1 @@ -152,7 +152,7 @@ Function New-LMDeviceDatasourceInstance { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDeviceDatasourceInstanceGroup.ps1 b/Public/New-LMDeviceDatasourceInstanceGroup.ps1 index 3b6a454..7e765e4 100644 --- a/Public/New-LMDeviceDatasourceInstanceGroup.ps1 +++ b/Public/New-LMDeviceDatasourceInstanceGroup.ps1 @@ -106,7 +106,7 @@ Function New-LMDeviceDatasourceInstanceGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDeviceDatasourceInstanceSDT.ps1 b/Public/New-LMDeviceDatasourceInstanceSDT.ps1 index e15dc7e..5ace878 100644 --- a/Public/New-LMDeviceDatasourceInstanceSDT.ps1 +++ b/Public/New-LMDeviceDatasourceInstanceSDT.ps1 @@ -87,11 +87,11 @@ Function New-LMDeviceDatasourceInstanceSDT { [Parameter(Mandatory, ParameterSetName = 'Weekly')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek')] - [ValidateSet("Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday","Sunday")] + [ValidateSet("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")] [String]$WeekDay, [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek')] - [ValidateSet("First", "Second", "Third","Fourth","Last")] + [ValidateSet("First", "Second", "Third", "Fourth", "Last")] [String]$WeekOfMonth, [Parameter(Mandatory, ParameterSetName = 'Monthly')] @@ -108,27 +108,27 @@ Function New-LMDeviceDatasourceInstanceSDT { #Build header and uri $ResourcePath = "/sdt/sdts" - Switch -Wildcard ($PSCmdlet.ParameterSetName){ - "OneTime*" {$Occurance = "oneTime"} - "Daily*" {$Occurance = "daily"} - "Monthly*" {$Occurance = "monthly"} - "MonthlyByWeek*" {$Occurance = "monthlyByWeek"} - "Weekly*" {$Occurance = "weekly"} + Switch -Wildcard ($PSCmdlet.ParameterSetName) { + "OneTime*" { $Occurance = "oneTime" } + "Daily*" { $Occurance = "daily" } + "Monthly*" { $Occurance = "monthly" } + "MonthlyByWeek*" { $Occurance = "monthlyByWeek" } + "Weekly*" { $Occurance = "weekly" } } Try { $Data = $null $Data = @{ - comment = $Comment - dataSourceInstanceId = $DeviceDataSourceInstanceId - sdtType = $Occurance + comment = $Comment + dataSourceInstanceId = $DeviceDataSourceInstanceId + sdtType = $Occurance #timezone = $Timezone - type = "DeviceDataSourceInstanceSDT" + type = "DeviceDataSourceInstanceSDT" } - Switch ($Occurance){ - "onetime" { + Switch ($Occurance) { + "onetime" { #Get UTC time based on selected timezone # $TimeZoneID = [System.TimeZoneInfo]::FindSystemTimeZoneById($Timezone) # $StartUTCTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($StartDate.ToUniversalTime(), $TimeZoneID) @@ -139,43 +139,43 @@ Function New-LMDeviceDatasourceInstanceSDT { $StartDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $StartDate.ToUniversalTime()).TotalMilliseconds $EndDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $EndDate.ToUniversalTime()).TotalMilliseconds - $Data.Add('endDateTime',[math]::Round($EndDateTime)) - $Data.Add('startDateTime',[math]::Round($StartDateTime)) - } - - "daily" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - } + $Data.Add('endDateTime', [math]::Round($EndDateTime)) + $Data.Add('startDateTime', [math]::Round($StartDateTime)) + } + + "daily" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + } - "weekly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - } + "weekly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + } - "monthly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('monthDay',$DayOfMonth) - } + "monthly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('monthDay', $DayOfMonth) + } - "monthlyByWeek" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - $Data.Add('weekOfMonth',$WeekOfMonth) - } - - default {} + "monthlyByWeek" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + $Data.Add('weekOfMonth', $WeekOfMonth) + } + + default {} } #Remove empty keys so we dont overwrite them @@ -188,7 +188,7 @@ Function New-LMDeviceDatasourceInstanceSDT { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDeviceDatasourceSDT.ps1 b/Public/New-LMDeviceDatasourceSDT.ps1 index ecbdb23..bba0c39 100644 --- a/Public/New-LMDeviceDatasourceSDT.ps1 +++ b/Public/New-LMDeviceDatasourceSDT.ps1 @@ -82,11 +82,11 @@ Function New-LMDeviceDatasourceSDT { [Parameter(Mandatory, ParameterSetName = 'Weekly')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek')] - [ValidateSet("Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday","Sunday")] + [ValidateSet("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")] [String]$WeekDay, [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek')] - [ValidateSet("First", "Second", "Third","Fourth","Last")] + [ValidateSet("First", "Second", "Third", "Fourth", "Last")] [String]$WeekOfMonth, [Parameter(Mandatory, ParameterSetName = 'Monthly')] @@ -103,27 +103,27 @@ Function New-LMDeviceDatasourceSDT { #Build header and uri $ResourcePath = "/sdt/sdts" - Switch -Wildcard ($PSCmdlet.ParameterSetName){ - "OneTime*" {$Occurance = "oneTime"} - "Daily*" {$Occurance = "daily"} - "Monthly*" {$Occurance = "monthly"} - "MonthlyByWeek*" {$Occurance = "monthlyByWeek"} - "Weekly*" {$Occurance = "weekly"} + Switch -Wildcard ($PSCmdlet.ParameterSetName) { + "OneTime*" { $Occurance = "oneTime" } + "Daily*" { $Occurance = "daily" } + "Monthly*" { $Occurance = "monthly" } + "MonthlyByWeek*" { $Occurance = "monthlyByWeek" } + "Weekly*" { $Occurance = "weekly" } } Try { $Data = $null $Data = @{ - comment = $Comment - deviceDataSourceId = $deviceDataSourceId - sdtType = $Occurance + comment = $Comment + deviceDataSourceId = $deviceDataSourceId + sdtType = $Occurance #timezone = $Timezone - type = "DeviceDataSourceSDT" + type = "DeviceDataSourceSDT" } - Switch ($Occurance){ - "onetime" { + Switch ($Occurance) { + "onetime" { #Get UTC time based on selected timezone # $TimeZoneID = [System.TimeZoneInfo]::FindSystemTimeZoneById($Timezone) # $StartUTCTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($StartDate.ToUniversalTime(), $TimeZoneID) @@ -134,43 +134,43 @@ Function New-LMDeviceDatasourceSDT { $StartDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $StartDate.ToUniversalTime()).TotalMilliseconds $EndDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $EndDate.ToUniversalTime()).TotalMilliseconds - $Data.Add('endDateTime',[math]::Round($EndDateTime)) - $Data.Add('startDateTime',[math]::Round($StartDateTime)) - } - - "daily" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - } + $Data.Add('endDateTime', [math]::Round($EndDateTime)) + $Data.Add('startDateTime', [math]::Round($StartDateTime)) + } + + "daily" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + } - "weekly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - } + "weekly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + } - "monthly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('monthDay',$DayOfMonth) - } + "monthly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('monthDay', $DayOfMonth) + } - "monthlyByWeek" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - $Data.Add('weekOfMonth',$WeekOfMonth) - } - - default {} + "monthlyByWeek" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + $Data.Add('weekOfMonth', $WeekOfMonth) + } + + default {} } #Remove empty keys so we dont overwrite them @@ -183,7 +183,7 @@ Function New-LMDeviceDatasourceSDT { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDeviceGroup.ps1 b/Public/New-LMDeviceGroup.ps1 index 4a107d2..d2cc599 100644 --- a/Public/New-LMDeviceGroup.ps1 +++ b/Public/New-LMDeviceGroup.ps1 @@ -113,7 +113,7 @@ Function New-LMDeviceGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.DeviceGroup" ) diff --git a/Public/New-LMDeviceGroupSDT.ps1 b/Public/New-LMDeviceGroupSDT.ps1 index be1094c..02b60dc 100644 --- a/Public/New-LMDeviceGroupSDT.ps1 +++ b/Public/New-LMDeviceGroupSDT.ps1 @@ -102,12 +102,12 @@ Function New-LMDeviceGroupSDT { [Parameter(Mandatory, ParameterSetName = 'Weekly-DeviceGroupName')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceGroupId')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceGroupName')] - [ValidateSet("Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday","Sunday")] + [ValidateSet("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")] [String]$WeekDay, [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceGroupId')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceGroupName')] - [ValidateSet("First", "Second", "Third","Fourth","Last")] + [ValidateSet("First", "Second", "Third", "Fourth", "Last")] [String]$WeekOfMonth, [Parameter(Mandatory, ParameterSetName = 'Monthly-DeviceGroupId')] @@ -146,12 +146,12 @@ Function New-LMDeviceGroupSDT { $DeviceGroupId = $LookupResult } - Switch -Wildcard ($PSCmdlet.ParameterSetName){ - "OneTime-Device*" {$Occurance = "oneTime"} - "Daily-Device*" {$Occurance = "daily"} - "Monthly-Device*" {$Occurance = "monthly"} - "MonthlyByWeek-Device*" {$Occurance = "monthlyByWeek"} - "Weekly-Device*" {$Occurance = "weekly"} + Switch -Wildcard ($PSCmdlet.ParameterSetName) { + "OneTime-Device*" { $Occurance = "oneTime" } + "Daily-Device*" { $Occurance = "daily" } + "Monthly-Device*" { $Occurance = "monthly" } + "MonthlyByWeek-Device*" { $Occurance = "monthlyByWeek" } + "Weekly-Device*" { $Occurance = "weekly" } } #Build header and uri @@ -161,15 +161,15 @@ Function New-LMDeviceGroupSDT { $Data = $null $Data = @{ - comment = $Comment - deviceGroupId = $DeviceGroupId - sdtType = $Occurance + comment = $Comment + deviceGroupId = $DeviceGroupId + sdtType = $Occurance #timezone = $Timezone - type = "ResourceGroupSDT" + type = "ResourceGroupSDT" } - Switch ($Occurance){ - "onetime" { + Switch ($Occurance) { + "onetime" { #Get UTC time based on selected timezone # $TimeZoneID = [System.TimeZoneInfo]::FindSystemTimeZoneById($Timezone) # $StartUTCTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($StartDate.ToUniversalTime(), $TimeZoneID) @@ -180,43 +180,43 @@ Function New-LMDeviceGroupSDT { $StartDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $StartDate.ToUniversalTime()).TotalMilliseconds $EndDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $EndDate.ToUniversalTime()).TotalMilliseconds - $Data.Add('endDateTime',[math]::Round($EndDateTime)) - $Data.Add('startDateTime',[math]::Round($StartDateTime)) - } - - "daily" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - } + $Data.Add('endDateTime', [math]::Round($EndDateTime)) + $Data.Add('startDateTime', [math]::Round($StartDateTime)) + } + + "daily" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + } - "weekly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - } + "weekly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + } - "monthly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('monthDay',$DayOfMonth) - } + "monthly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('monthDay', $DayOfMonth) + } - "monthlyByWeek" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - $Data.Add('weekOfMonth',$WeekOfMonth) - } - - default {} + "monthlyByWeek" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + $Data.Add('weekOfMonth', $WeekOfMonth) + } + + default {} } #Remove empty keys so we dont overwrite them @@ -229,7 +229,7 @@ Function New-LMDeviceGroupSDT { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDeviceProperty.ps1 b/Public/New-LMDeviceProperty.ps1 index 483f23e..719e2cd 100644 --- a/Public/New-LMDeviceProperty.ps1 +++ b/Public/New-LMDeviceProperty.ps1 @@ -79,7 +79,7 @@ Function New-LMDeviceProperty { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMDeviceSDT.ps1 b/Public/New-LMDeviceSDT.ps1 index 02f63fe..9e61f3d 100644 --- a/Public/New-LMDeviceSDT.ps1 +++ b/Public/New-LMDeviceSDT.ps1 @@ -110,12 +110,12 @@ Function New-LMDeviceSDT { [Parameter(Mandatory, ParameterSetName = 'Weekly-DeviceName')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceId')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceName')] - [ValidateSet("Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday","Sunday")] + [ValidateSet("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")] [String]$WeekDay, [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceId')] [Parameter(Mandatory, ParameterSetName = 'MonthlyByWeek-DeviceName')] - [ValidateSet("First", "Second", "Third","Fourth","Last")] + [ValidateSet("First", "Second", "Third", "Fourth", "Last")] [String]$WeekOfMonth, [Parameter(Mandatory, ParameterSetName = 'Monthly-DeviceId')] @@ -136,12 +136,12 @@ Function New-LMDeviceSDT { $DeviceId = $LookupResult } - Switch -Wildcard ($PSCmdlet.ParameterSetName){ - "OneTime-Device*" {$Occurance = "oneTime"} - "Daily-Device*" {$Occurance = "daily"} - "Monthly-Device*" {$Occurance = "monthly"} - "MonthlyByWeek-Device*" {$Occurance = "monthlyByWeek"} - "Weekly-Device*" {$Occurance = "weekly"} + Switch -Wildcard ($PSCmdlet.ParameterSetName) { + "OneTime-Device*" { $Occurance = "oneTime" } + "Daily-Device*" { $Occurance = "daily" } + "Monthly-Device*" { $Occurance = "monthly" } + "MonthlyByWeek-Device*" { $Occurance = "monthlyByWeek" } + "Weekly-Device*" { $Occurance = "weekly" } } #Build header and uri @@ -151,15 +151,15 @@ Function New-LMDeviceSDT { $Data = $null $Data = @{ - comment = $Comment - deviceId = $DeviceId - sdtType = $Occurance + comment = $Comment + deviceId = $DeviceId + sdtType = $Occurance #timezone = $Timezone - type = "ResourceSDT" + type = "ResourceSDT" } - Switch ($Occurance){ - "onetime" { + Switch ($Occurance) { + "onetime" { #Get UTC time based on selected timezone # $TimeZoneID = [System.TimeZoneInfo]::FindSystemTimeZoneById($Timezone) # $StartUTCTime = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date $StartDate).ToUniversalTime(), $TimeZoneID) @@ -171,43 +171,43 @@ Function New-LMDeviceSDT { $StartDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $StartDate.ToUniversalTime()).TotalMilliseconds $EndDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $EndDate.ToUniversalTime()).TotalMilliseconds - $Data.Add('endDateTime',[math]::Round($EndDateTime)) - $Data.Add('startDateTime',[math]::Round($StartDateTime)) - } - - "daily" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - } + $Data.Add('endDateTime', [math]::Round($EndDateTime)) + $Data.Add('startDateTime', [math]::Round($StartDateTime)) + } + + "daily" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + } - "weekly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - } + "weekly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + } - "monthly" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('monthDay',$DayOfMonth) - } + "monthly" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('monthDay', $DayOfMonth) + } - "monthlyByWeek" { - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - $Data.Add('weekOfMonth',$WeekOfMonth) - } - - default {} + "monthlyByWeek" { + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + $Data.Add('weekOfMonth', $WeekOfMonth) + } + + default {} } #Remove empty keys so we dont overwrite them @@ -220,7 +220,7 @@ Function New-LMDeviceSDT { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMEnhancedNetscan.ps1 b/Public/New-LMEnhancedNetscan.ps1 index 734786f..ffa19a2 100644 --- a/Public/New-LMEnhancedNetscan.ps1 +++ b/Public/New-LMEnhancedNetscan.ps1 @@ -95,10 +95,10 @@ Function New-LMEnhancedNetScan { $ResourcePath = "/setting/netscans" #Get Netscan GroupID - If($NetScanGroupName){ + If ($NetScanGroupName) { $NetScanGroupId = (Get-LMNetScanGroup -Name $NetScanGroupName).Id } - Else{ + Else { $NetScanGroupId = 1 } @@ -134,19 +134,19 @@ Function New-LMEnhancedNetScan { Try { $Data = @{ - name = $Name - collector = $CollectorId - description = $Description - duplicate = $Duplicates - method = $Method - nextStart = $NextStart - groovyScript = $GroovyScript - nextStartEpoch = $NextStartEpoch - nsgId = $NetScanGroupId - credentials = $Creds - filters = $Filters - schedule = $Schedule - scriptType = "embeded" + name = $Name + collector = $CollectorId + description = $Description + duplicate = $Duplicates + method = $Method + nextStart = $NextStart + groovyScript = $GroovyScript + nextStartEpoch = $NextStartEpoch + nsgId = $NetScanGroupId + credentials = $Creds + filters = $Filters + schedule = $Schedule + scriptType = "embeded" } diff --git a/Public/New-LMNetscanGroup.ps1 b/Public/New-LMNetscanGroup.ps1 index 4ada040..8815a3d 100644 --- a/Public/New-LMNetscanGroup.ps1 +++ b/Public/New-LMNetscanGroup.ps1 @@ -45,8 +45,8 @@ Function New-LMNetscanGroup { Try { $Data = @{ - description = $Description - name = $Name + description = $Description + name = $Name } diff --git a/Public/New-LMOpsNote.ps1 b/Public/New-LMOpsNote.ps1 index b59c445..3197522 100644 --- a/Public/New-LMOpsNote.ps1 +++ b/Public/New-LMOpsNote.ps1 @@ -51,41 +51,41 @@ Function New-LMOpsNote { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If(!$NoteDate){ + If (!$NoteDate) { [int64]$NoteDate = [DateTimeOffset]::Now.ToUnixTimeSeconds() } - Else{ + Else { $Epoch = Get-Date -Date "01/01/1970" [int64]$NoteDate = (New-TimeSpan -Start $Epoch -End $NoteDate.ToUniversalTime()).TotalSeconds } $Scope = @() - If($ResourceIds -or $WebsiteIds -or $DeviceGroupIds){ - Foreach($id in $DeviceIds){ + If ($ResourceIds -or $WebsiteIds -or $DeviceGroupIds) { + Foreach ($id in $DeviceIds) { $Scope += [PSCustomObject]@{ - type = "device" - groupId = "0" + type = "device" + groupId = "0" deviceId = $id } } - Foreach($id in $WebsiteIds){ + Foreach ($id in $WebsiteIds) { $Scope += [PSCustomObject]@{ - type = "website" - groupId = "0" + type = "website" + groupId = "0" websiteId = $id } } - Foreach($id in $DeviceGroupIds){ + Foreach ($id in $DeviceGroupIds) { $Scope += @{ - type = "deviceGroup" + type = "deviceGroup" groupId = $id } } } $TagList = @() - Foreach($tag in $Tags){ - $TagList += @{name = $tag} + Foreach ($tag in $Tags) { + $TagList += @{name = $tag } } @@ -110,7 +110,7 @@ Function New-LMOpsNote { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return $Response diff --git a/Public/New-LMPushMetricDataPoint.ps1 b/Public/New-LMPushMetricDataPoint.ps1 index ddcd936..40911ea 100644 --- a/Public/New-LMPushMetricDataPoint.ps1 +++ b/Public/New-LMPushMetricDataPoint.ps1 @@ -47,27 +47,27 @@ Function New-LMPushMetricDataPoint { [System.Collections.Generic.List[object]]$DataPoints, # object with datapoint name and value [ValidateSet("counter", "derive", "gauge")] [String]$DataPointType = "gauge", - [ValidateSet("min", "max", "avg","sum","none","percentile")] + [ValidateSet("min", "max", "avg", "sum", "none", "percentile")] [String]$DataPointAggregationType = "none", [ValidateRange(0, 100)] [Int]$PercentileValue ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If(!$DataPointsArray){ + If (!$DataPointsArray) { $DataPointsArray = [System.Collections.Generic.List[object]]::New() } #Add each datapoint to new datapoint array - Foreach($Datapoint in $DataPoints){ + Foreach ($Datapoint in $DataPoints) { $DataPointsArray.Add([PSCustomObject]@{ - dataPointName = $Datapoint.Name - dataPointType = $DataPointType - dataPointDescription = ($Datapoint.Description -replace '“|”','') - dataPointAggregationType = $DataPointAggregationType - percentileValue = $PercentileValue - values = @{$((Get-Date -UFormat %s).Split(".")[0])=$Datapoint.Value} - }) + dataPointName = $Datapoint.Name + dataPointType = $DataPointType + dataPointDescription = ($Datapoint.Description -replace '“|”', '') + dataPointAggregationType = $DataPointAggregationType + percentileValue = $PercentileValue + values = @{$((Get-Date -UFormat %s).Split(".")[0]) = $Datapoint.Value } + }) } Return $DataPointsArray diff --git a/Public/New-LMPushMetricInstance.ps1 b/Public/New-LMPushMetricInstance.ps1 index b0a1a0c..1e228ce 100644 --- a/Public/New-LMPushMetricInstance.ps1 +++ b/Public/New-LMPushMetricInstance.ps1 @@ -36,7 +36,7 @@ Function New-LMPushMetricInstance { [CmdletBinding()] Param ( - [System.Collections.Generic.List[object]]$InstancesArrary, + [System.Collections.Generic.List[object]]$InstancesArrary, [Parameter(Mandatory)] [String]$InstanceName, @@ -52,18 +52,18 @@ Function New-LMPushMetricInstance { ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If(!$InstancesArrary){ + If (!$InstancesArrary) { $InstancesArrary = [System.Collections.Generic.List[object]]::New() } #Add new instance to new instances array $InstancesArrary.Add([PSCustomObject]@{ - instanceName = $InstanceName - instanceDisplayName = If($InstanceDisplayName){$InstanceDisplayName}Else{$InstanceName} - instanceProperties = $InstanceProperties - instanceDescription = $InstanceDescription - dataPoints = $Datapoints - }) + instanceName = $InstanceName + instanceDisplayName = If ($InstanceDisplayName) { $InstanceDisplayName }Else { $InstanceName } + instanceProperties = $InstanceProperties + instanceDescription = $InstanceDescription + dataPoints = $Datapoints + }) Return $InstancesArrary } diff --git a/Public/New-LMReportGroup.ps1 b/Public/New-LMReportGroup.ps1 index 501fd5e..e261283 100644 --- a/Public/New-LMReportGroup.ps1 +++ b/Public/New-LMReportGroup.ps1 @@ -49,8 +49,8 @@ Function New-LMReportGroup { Try { $Data = @{ - description = $Description - name = $Name + description = $Description + name = $Name } diff --git a/Public/New-LMRole.ps1 b/Public/New-LMRole.ps1 index dadaae2..9fe2d76 100644 --- a/Public/New-LMRole.ps1 +++ b/Public/New-LMRole.ps1 @@ -90,8 +90,8 @@ Function New-LMRole { [CmdletBinding(DefaultParameterSetName = 'Default')] Param ( - [Parameter(Mandatory,ParameterSetName = 'Custom')] - [Parameter(Mandatory,ParameterSetName = 'Default')] + [Parameter(Mandatory, ParameterSetName = 'Custom')] + [Parameter(Mandatory, ParameterSetName = 'Default')] [String]$Name, [Parameter(ParameterSetName = 'Default')] @@ -119,39 +119,39 @@ Function New-LMRole { [String]$RoleGroupId = 1, [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$DashboardsPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$ResourcePermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$LogsPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$WebsitesPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$SavedMapsPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$ReportsPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view","manage","commit","publish","none")] + [ValidateSet("view", "manage", "commit", "publish", "none")] [String]$LMXToolBoxPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view","install","none")] + [ValidateSet("view", "install", "none")] [String]$LMXPermission = "none", [Parameter(ParameterSetName = 'Default')] - [ValidateSet("view", "manage","none","manage-collectors","view-collectors")] + [ValidateSet("view", "manage", "none", "manage-collectors", "view-collectors")] [String]$SettingsPermission = "none", [Parameter(ParameterSetName = 'Default')] @@ -178,7 +178,7 @@ Function New-LMRole { [Parameter(ParameterSetName = 'Default')] [Switch]$EnableRemoteSessionForResources, - [Parameter(Mandatory,ParameterSetName = 'Custom')] + [Parameter(Mandatory, ParameterSetName = 'Custom')] [PSCustomObject]$CustomPrivilegesObject ) @@ -190,202 +190,202 @@ Function New-LMRole { $ResourcePath = "/setting/roles" $Privileges = @() - If(!$CustomPrivilegesObject){ + If (!$CustomPrivilegesObject) { - If($ViewTraces){ + If ($ViewTraces) { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "tracesManageTab" - operation = "read" + objectId = "*" + objectName = "*" + objectType = "tracesManageTab" + operation = "read" subOperation = "" } } - If($EnableRemoteSessionForResources){ + If ($EnableRemoteSessionForResources) { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "remoteSession" - operation = "write" + objectId = "*" + objectName = "*" + objectType = "remoteSession" + operation = "write" subOperation = "" } } - If($AllowedToViewMapsTab){ + If ($AllowedToViewMapsTab) { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "resourceMapTab" - operation = "read" + objectId = "*" + objectName = "*" + objectType = "resourceMapTab" + operation = "read" subOperation = "" } } - If($AllowWidgetSharing){ + If ($AllowWidgetSharing) { $Privileges += [PSCustomObject]@{ - objectId = "sharingwidget" - objectName = "sharingwidget" - objectType = "dashboard_group" - operation = "write" + objectId = "sharingwidget" + objectName = "sharingwidget" + objectType = "dashboard_group" + operation = "write" subOperation = "" } } - If($CreatePrivateDashboards){ + If ($CreatePrivateDashboards) { $Privileges += [PSCustomObject]@{ - objectId = "private" - objectName = "private" - objectType = "dashboard_group" - operation = "write" + objectId = "private" + objectName = "private" + objectType = "dashboard_group" + operation = "write" subOperation = "" } } - If($LMXToolBoxPermission){ + If ($LMXToolBoxPermission) { $Privileges += [PSCustomObject]@{ - objectId = "allinstalledmodules" + objectId = "allinstalledmodules" objectName = "All installed modules" objectType = "module" - operation = $LMXToolBoxPermission + operation = $LMXToolBoxPermission } } - If($LMXPermission){ + If ($LMXPermission) { $Privileges += [PSCustomObject]@{ - objectId = "All exchange modules" + objectId = "All exchange modules" objectName = "private" objectType = "module" - operation = $LMXPermission + operation = $LMXPermission } } - If($ViewSupport){ + If ($ViewSupport) { $Privileges += [PSCustomObject]@{ - objectId = "chat" - objectName = "help" - objectType = "help" - operation = "write" + objectId = "chat" + objectName = "help" + objectType = "help" + operation = "write" subOperation = "" } $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "help" - objectType = "help" - operation = "read" + objectId = "*" + objectName = "help" + objectType = "help" + operation = "read" subOperation = "" } } - Else{ + Else { $Privileges += [PSCustomObject]@{ - objectId = "chat" - objectName = "help" - objectType = "help" - operation = "read" + objectId = "chat" + objectName = "help" + objectType = "help" + operation = "read" subOperation = "" } } $Privileges += [PSCustomObject]@{ - objectId = "" - objectName = "configNeedDeviceManagePermission" - objectType = "configNeedDeviceManagePermission" - operation = If($ConfigTabRequiresManagePermission){"write"}Else{"read"} + objectId = "" + objectName = "configNeedDeviceManagePermission" + objectType = "configNeedDeviceManagePermission" + operation = If ($ConfigTabRequiresManagePermission) { "write" }Else { "read" } subOperation = "" } $Privileges += [PSCustomObject]@{ - objectId = "" - objectName = "deviceDashboard" - objectType = "deviceDashboard" - operation = If($AllowedToManageResourceDashboards){"write"}Else{"read"} + objectId = "" + objectName = "deviceDashboard" + objectType = "deviceDashboard" + operation = If ($AllowedToManageResourceDashboards) { "write" }Else { "read" } subOperation = "" } - If($DashboardsPermission -ne "none"){ + If ($DashboardsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "dashboard_group" - operation = If($DashboardsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "dashboard_group" + operation = If ($DashboardsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($ResourcePermission -ne "none"){ + If ($ResourcePermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "host_group" - operation = If($ResourcePermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "host_group" + operation = If ($ResourcePermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($LogsPermission -ne "none"){ + If ($LogsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "logs" - operation = If($LogsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "logs" + operation = If ($LogsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($WebsitesPermission -ne "none"){ + If ($WebsitesPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "website_group" - operation = If($WebsitesPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "website_group" + operation = If ($WebsitesPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($SavedMapsPermission -ne "none"){ + If ($SavedMapsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "map" - operation = If($SavedMapsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "map" + operation = If ($SavedMapsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($ReportsPermission -ne "none"){ + If ($ReportsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "report_group" - operation = If($ReportsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "report_group" + operation = If ($ReportsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($SettingsPermission -ne "none"){ - If($SettingsPermission -ne "manage-collectors" -and $SettingsPermission -ne "view-collectors"){ + If ($SettingsPermission -ne "none") { + If ($SettingsPermission -ne "manage-collectors" -and $SettingsPermission -ne "view-collectors") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "setting" - operation = If($SettingsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "setting" + operation = If ($SettingsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } $Privileges += [PSCustomObject]@{ - objectId = "useraccess.*" - objectName = "useraccess.*" - objectType = "setting" - operation = If($ResourcePermission -eq "manage"){"write"}Else{"read"} + objectId = "useraccess.*" + objectName = "useraccess.*" + objectType = "setting" + operation = If ($ResourcePermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - Else{ + Else { $Privileges += [PSCustomObject]@{ - objectId = "collectorgroup.*" + objectId = "collectorgroup.*" objectName = "Collectors" objectType = "setting" - operation = If($SettingsPermission -eq "manage-collectors"){"write"}Else{"read"} + operation = If ($SettingsPermission -eq "manage-collectors") { "write" }Else { "read" } } } } @@ -398,10 +398,10 @@ Function New-LMRole { customHelpURL = $CustomHelpURL description = $Description name = $Name - requireEULA = $RequireEULA.IsPresent + requireEULA = $RequireEULA.IsPresent roleGroupId = $RoleGroupId twoFARequired = $TwoFARequired - privileges = If($CustomPrivilegesObject){$CustomPrivilegesObject}Else{$Privileges} + privileges = If ($CustomPrivilegesObject) { $CustomPrivilegesObject }Else { $Privileges } } #Remove empty keys so we dont overwrite them @@ -414,7 +414,7 @@ Function New-LMRole { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.Role" ) diff --git a/Public/New-LMUser.ps1 b/Public/New-LMUser.ps1 index 2f66e0d..39746e5 100644 --- a/Public/New-LMUser.ps1 +++ b/Public/New-LMUser.ps1 @@ -166,7 +166,7 @@ Function New-LMUser { #Auto generate password if not provided $AutoGeneratePassword = $False - If(!$Password){ + If (!$Password) { $Password = New-LMRandomCred $AutoGeneratePassword = $True } @@ -206,16 +206,16 @@ Function New-LMUser { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data - If($AutoGeneratePassword){ - If(!$global:LMUserData){ + If ($AutoGeneratePassword) { + If (!$global:LMUserData) { $UserData = New-Object System.Collections.ArrayList - $UserData.Add([PSCustomObject]@{"Username"=$Username;"Temp_Password"=$Password}) | Out-Null + $UserData.Add([PSCustomObject]@{"Username" = $Username; "Temp_Password" = $Password }) | Out-Null New-Variable -Name LMUserData -Scope global -Value $UserData } - Else{ - $global:LMUserData.Add([PSCustomObject]@{"Username"=$Username;"Temp_Password"=$Password}) | Out-Null + Else { + $global:LMUserData.Add([PSCustomObject]@{"Username" = $Username; "Temp_Password" = $Password }) | Out-Null } Write-LMHost "[INFO]: Auto generated password assigned to $Username`: $Password" -ForegroundColor Yellow diff --git a/Public/New-LMWebsite.ps1 b/Public/New-LMWebsite.ps1 index 543551f..0516cc4 100644 --- a/Public/New-LMWebsite.ps1 +++ b/Public/New-LMWebsite.ps1 @@ -107,10 +107,10 @@ Function New-LMWebsite { [CmdletBinding()] Param ( - [Parameter(Mandatory,ParameterSetName="Website")] + [Parameter(Mandatory, ParameterSetName = "Website")] [Switch]$WebCheck, - [Parameter(Mandatory,ParameterSetName="Ping")] + [Parameter(Mandatory, ParameterSetName = "Ping")] [Switch]$PingCheck, [Parameter(Mandatory)] @@ -128,41 +128,41 @@ Function New-LMWebsite { [Nullable[boolean]]$UseDefaultLocationSetting = $true, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[boolean]]$TriggerSSLStatusAlert, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[boolean]]$TriggerSSLExpirationAlert, [String]$GroupId, - [Parameter(Mandatory,ParameterSetName="Ping")] + [Parameter(Mandatory, ParameterSetName = "Ping")] [String]$PingAddress, - [Parameter(Mandatory,ParameterSetName="Website")] + [Parameter(Mandatory, ParameterSetName = "Website")] [String]$WebsiteDomain, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [ValidateSet("http", "https")] [String]$HttpType = "https", - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [String[]]$SSLAlertThresholds, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [ValidateSet(5, 10, 15, 20, 30, 60)] [Nullable[Int]]$PingCount, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [Nullable[Int]]$PingTimeout, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[Int]]$PageLoadAlertTimeInMS, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[boolean]]$IgnoreSSL, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [ValidateSet(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)] [Nullable[Int]]$PingPercentNotReceived, @@ -183,29 +183,29 @@ Function New-LMWebsite { [ValidateSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)] [Nullable[Int]]$PollingInterval, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Object[]]$WebsiteSteps, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Object[]]$CheckPoints ) #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($Webcheck){ + If ($Webcheck) { $Type = "webcheck" } - Else{ + Else { $Type = "pingcheck" } $Steps = @() If ($Type -eq "webcheck") { - If($WebsiteSteps){ + If ($WebsiteSteps) { $Steps = $WebsiteSteps } - Else{ + Else { $Steps += [PSCustomObject]@{ useDefaultRoot = $true url = "" @@ -279,18 +279,18 @@ Function New-LMWebsite { steps = $Steps } - If($CheckPoints){ + If ($CheckPoints) { $TestLocations = [PSCustomObject]@{ - all = $true - smgIds = @() - collectorIds = @($CheckPoints.smgId.GetEnumerator() | Foreach-Object {If($_ -ne 0){[Int]$_}}) + all = $true + smgIds = @() + collectorIds = @($CheckPoints.smgId.GetEnumerator() | ForEach-Object { If ($_ -ne 0) { [Int]$_ } }) } - $Data.checkpoints = $CheckPoints + $Data.checkpoints = $CheckPoints $Data.testLocation = $TestLocations } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "testLocation" -and $_ -ne "steps" -and $_ -ne "checkpoints") { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "testLocation" -and $_ -ne "steps" -and $_ -ne "checkpoints") { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json -Depth 5) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMWebsiteGroup.ps1 b/Public/New-LMWebsiteGroup.ps1 index d7f00ff..98091d3 100644 --- a/Public/New-LMWebsiteGroup.ps1 +++ b/Public/New-LMWebsiteGroup.ps1 @@ -102,7 +102,7 @@ Function New-LMWebsiteGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.WebsiteGroup" ) diff --git a/Public/Remove-LMAPIToken.ps1 b/Public/Remove-LMAPIToken.ps1 index 98ef4b1..0c64d8f 100644 --- a/Public/Remove-LMAPIToken.ps1 +++ b/Public/Remove-LMAPIToken.ps1 @@ -42,7 +42,7 @@ This function requires a valid API authentication. Make sure to log in using Con #> Function Remove-LMAPIToken { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id')] [Int]$UserId, @@ -58,8 +58,8 @@ Function Remove-LMAPIToken { [Int]$APITokenId ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -72,7 +72,7 @@ Function Remove-LMAPIToken { $UserId = $LookupResult } - If($AccessId){ + If ($AccessId) { $LookupResult = (Get-LMAPIToken -AccessId $AccessId) If (Test-LookupResult -Result $LookupResult -LookupString $AccessId) { return @@ -84,10 +84,10 @@ Function Remove-LMAPIToken { #Build header and uri $ResourcePath = "/setting/admins/$UserId/apitokens/$APITokenId" - If($PSItem){ + If ($PSItem) { $Message = "Id: $APITokenId | AccessId: $($PSItem.accessId)| AdminName:$($PSItem.adminName)" } - Else{ + Else { $Message = "Id: $APITokenId" } @@ -98,11 +98,11 @@ Function Remove-LMAPIToken { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $APITokenId + Id = $APITokenId Message = "Successfully removed ($Message)" } @@ -120,5 +120,5 @@ Function Remove-LMAPIToken { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMAppliesToFunction.ps1 b/Public/Remove-LMAppliesToFunction.ps1 index 1ac2381..7282050 100644 --- a/Public/Remove-LMAppliesToFunction.ps1 +++ b/Public/Remove-LMAppliesToFunction.ps1 @@ -30,12 +30,12 @@ System.Management.Automation.PSCustomObject. The function returns an object with #> Function Remove-LMAppliesToFunction { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Name')] [String]$Name, - [Parameter(Mandatory, ParameterSetName = 'Id',ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id ) @@ -56,13 +56,13 @@ Function Remove-LMAppliesToFunction { #Build header and uri $ResourcePath = "/setting/functions/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name:$($PSItem.name)" } ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -73,11 +73,11 @@ Function Remove-LMAppliesToFunction { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMCachedAccount.ps1 b/Public/Remove-LMCachedAccount.ps1 index 952ab36..f34fd7e 100644 --- a/Public/Remove-LMCachedAccount.ps1 +++ b/Public/Remove-LMCachedAccount.ps1 @@ -24,7 +24,7 @@ Removes all cached accounts from the Logic.Monitor vault. #> Function Remove-LMCachedAccount { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Single', ValueFromPipelineByPropertyName)] [Alias("Portal")] @@ -33,34 +33,34 @@ Function Remove-LMCachedAccount { [Parameter(ParameterSetName = 'All')] [Switch]$RemoveAllEntries ) - Begin{} - Process{ - If($RemoveAllEntries){ + Begin {} + Process { + If ($RemoveAllEntries) { $CachedAccounts = Get-SecretInfo -Vault Logic.Monitor if ($PSCmdlet.ShouldProcess("$(($CachedAccounts | Measure-Object).Count) cached account(s)", "Remove All Cached Accounts")) { - Foreach ($Account in $CachedAccounts.Name){ - Try{ + Foreach ($Account in $CachedAccounts.Name) { + Try { Remove-Secret -Name $Account -Vault Logic.Monitor -Confirm:$false -ErrorAction Stop Write-Host "[INFO]: Removed cached account secret for: $Account" } - Catch{ + Catch { Write-Error $_.Exception.Message } } Write-Host "[INFO]: Processed all entries from credential cache" } } - Else{ + Else { If ($PSCmdlet.ShouldProcess($CachedAccountName, "Remove Cached Account")) { - Try{ + Try { Remove-Secret -Name $CachedAccountName -Vault Logic.Monitor -Confirm:$false -ErrorAction Stop Write-Host "[INFO]: Removed cached account secret for: $CachedAccountName" } - Catch{ + Catch { Write-Error $_.Exception.Message } } } } - End{} + End {} } \ No newline at end of file diff --git a/Public/Remove-LMCollectorGroup.ps1 b/Public/Remove-LMCollectorGroup.ps1 index 344dc32..53a0f9b 100644 --- a/Public/Remove-LMCollectorGroup.ps1 +++ b/Public/Remove-LMCollectorGroup.ps1 @@ -30,7 +30,7 @@ This function requires valid API credentials to be logged in. Use Connect-LMAcco #> Function Remove-LMCollectorGroup { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -53,13 +53,13 @@ Function Remove-LMCollectorGroup { $Id = $LookupResult } - If($PSItem){ + If ($PSItem) { $Message = "Id: $($PSItem.id) | Name: $($PSItem.name)" } ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -73,11 +73,11 @@ Function Remove-LMCollectorGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMConfigsource.ps1 b/Public/Remove-LMConfigsource.ps1 index 49aa15d..67631c4 100644 --- a/Public/Remove-LMConfigsource.ps1 +++ b/Public/Remove-LMConfigsource.ps1 @@ -33,7 +33,7 @@ Please ensure you are logged in before running any commands. Use Connect-LMAccou #> Function Remove-LMConfigsource { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -43,8 +43,8 @@ Function Remove-LMConfigsource { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -61,13 +61,13 @@ Function Remove-LMConfigsource { #Build header and uri $ResourcePath = "/setting/configsources/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -78,11 +78,11 @@ Function Remove-LMConfigsource { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -100,5 +100,5 @@ Function Remove-LMConfigsource { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMDashboard.ps1 b/Public/Remove-LMDashboard.ps1 index c86e357..b25d279 100644 --- a/Public/Remove-LMDashboard.ps1 +++ b/Public/Remove-LMDashboard.ps1 @@ -32,7 +32,7 @@ System.Management.Automation.PSCustomObject. The function returns an object with #> Function Remove-LMDashboard { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -41,8 +41,8 @@ Function Remove-LMDashboard { [String]$Name ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -58,13 +58,13 @@ Function Remove-LMDashboard { #Build header and uri $ResourcePath = "/dashboard/dashboards/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -75,11 +75,11 @@ Function Remove-LMDashboard { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -97,5 +97,5 @@ Function Remove-LMDashboard { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMDashboardGroup.ps1 b/Public/Remove-LMDashboardGroup.ps1 index b6b79f7..88bc08b 100644 --- a/Public/Remove-LMDashboardGroup.ps1 +++ b/Public/Remove-LMDashboardGroup.ps1 @@ -24,7 +24,7 @@ None. #> Function Remove-LMDashboardGroup { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -33,8 +33,8 @@ Function Remove-LMDashboardGroup { [String]$Name ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -50,13 +50,13 @@ Function Remove-LMDashboardGroup { #Build header and uri $ResourcePath = "/dashboard/groups/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -67,11 +67,11 @@ Function Remove-LMDashboardGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -89,5 +89,5 @@ Function Remove-LMDashboardGroup { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMDashboardWidget.ps1 b/Public/Remove-LMDashboardWidget.ps1 index 222222a..e8c4f83 100644 --- a/Public/Remove-LMDashboardWidget.ps1 +++ b/Public/Remove-LMDashboardWidget.ps1 @@ -33,7 +33,7 @@ This function requires a valid API authentication to Logic Monitor. Make sure to #> Function Remove-LMDashboardWidget { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -43,8 +43,8 @@ Function Remove-LMDashboardWidget { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -60,13 +60,13 @@ Function Remove-LMDashboardWidget { #Build header and uri $ResourcePath = "/dashboard/widgets/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -77,11 +77,11 @@ Function Remove-LMDashboardWidget { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -99,5 +99,5 @@ Function Remove-LMDashboardWidget { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMDatasource.ps1 b/Public/Remove-LMDatasource.ps1 index 2b5535f..efac969 100644 --- a/Public/Remove-LMDatasource.ps1 +++ b/Public/Remove-LMDatasource.ps1 @@ -34,7 +34,7 @@ System.Management.Automation.PSCustomObject #> Function Remove-LMDatasource { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -47,8 +47,8 @@ Function Remove-LMDatasource { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -73,10 +73,10 @@ Function Remove-LMDatasource { #Build header and uri $ResourcePath = "/setting/datasources/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - Else{ + Else { $Message = "Id: $Id" } @@ -87,11 +87,11 @@ Function Remove-LMDatasource { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -109,5 +109,5 @@ Function Remove-LMDatasource { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMDevice.ps1 b/Public/Remove-LMDevice.ps1 index 5f13929..165f8ee 100644 --- a/Public/Remove-LMDevice.ps1 +++ b/Public/Remove-LMDevice.ps1 @@ -37,7 +37,7 @@ Permanently deletes the LogicMonitor device with the name "MyDevice". #> Function Remove-LMDevice { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -62,13 +62,13 @@ Function Remove-LMDevice { $Id = $LookupResult } - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -84,11 +84,11 @@ Function Remove-LMDevice { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMDeviceDatasourceInstance.ps1 b/Public/Remove-LMDeviceDatasourceInstance.ps1 index fc75586..18f852d 100644 --- a/Public/Remove-LMDeviceDatasourceInstance.ps1 +++ b/Public/Remove-LMDeviceDatasourceInstance.ps1 @@ -37,7 +37,7 @@ A custom object with the following properties: - Message: A message indicating the success of the removal. #> Function Remove-LMDeviceDatasourceInstance { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] @@ -60,8 +60,8 @@ Function Remove-LMDeviceDatasourceInstance { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -93,13 +93,13 @@ Function Remove-LMDeviceDatasourceInstance { #Build header and uri $ResourcePath = "/device/devices/$DeviceId/devicedatasources/$HdsId/instances/$InstanceId" - If($PSItem){ + If ($PSItem) { $Message = "DeviceDisplayName: $($PSItem.deviceDisplayName) | DatasourceName: $($PSItem.name) | WildValue: $($PSItem.wildValue)" } - ElseIf($DatasourceName -and $DeviceName){ + ElseIf ($DatasourceName -and $DeviceName) { $Message = "DeviceName: $DeviceName | DatasourceName: $DatasourceName | WildValue: $WildValue" } - Else{ + Else { $Message = "DeviceId: $DeviceId | DatasourceId: $DatasourceId | WildValue: $WildValue" } @@ -110,12 +110,12 @@ Function Remove-LMDeviceDatasourceInstance { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ InstanceId = $InstanceId - Message = "Successfully removed ($Message)" + Message = "Successfully removed ($Message)" } Return $Result @@ -132,5 +132,5 @@ Function Remove-LMDeviceDatasourceInstance { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMDeviceGroup.ps1 b/Public/Remove-LMDeviceGroup.ps1 index 355a5a3..0a89619 100644 --- a/Public/Remove-LMDeviceGroup.ps1 +++ b/Public/Remove-LMDeviceGroup.ps1 @@ -61,13 +61,13 @@ Function Remove-LMDeviceGroup { $QueryParams = "?deleteChildren=$DeleteHostsandChildren&deleteHard=$HardDelete" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -78,11 +78,11 @@ Function Remove-LMDeviceGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMDeviceProperty.ps1 b/Public/Remove-LMDeviceProperty.ps1 index c761634..9c108f2 100644 --- a/Public/Remove-LMDeviceProperty.ps1 +++ b/Public/Remove-LMDeviceProperty.ps1 @@ -36,7 +36,7 @@ System.Management.Automation.PSCustomObject. The output object contains the foll #> Function Remove-LMDeviceProperty { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id')] [Int]$Id, @@ -65,10 +65,10 @@ Function Remove-LMDeviceProperty { #Build header and uri $ResourcePath = "/device/devices/$Id/properties/$PropertyName" - If($Name){ + If ($Name) { $Message = "Id: $Id | Name: $Name | Property: $PropertyName" } - Else{ + Else { $Message = "Id: $Id | Property: $PropertyName" } @@ -79,11 +79,11 @@ Function Remove-LMDeviceProperty { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -101,5 +101,5 @@ Function Remove-LMDeviceProperty { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMNetscan.ps1 b/Public/Remove-LMNetscan.ps1 index 80e7de9..8065b0f 100644 --- a/Public/Remove-LMNetscan.ps1 +++ b/Public/Remove-LMNetscan.ps1 @@ -29,7 +29,7 @@ System.Management.Automation.PSCustomObject. The function returns an object with #> Function Remove-LMNetscan { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -39,8 +39,8 @@ Function Remove-LMNetscan { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -56,13 +56,13 @@ Function Remove-LMNetscan { #Build header and uri $ResourcePath = "/setting/netscans/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -74,11 +74,11 @@ Function Remove-LMNetscan { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -96,5 +96,5 @@ Function Remove-LMNetscan { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMNetscanGroup.ps1 b/Public/Remove-LMNetscanGroup.ps1 index b30a027..8ee5a59 100644 --- a/Public/Remove-LMNetscanGroup.ps1 +++ b/Public/Remove-LMNetscanGroup.ps1 @@ -33,7 +33,7 @@ This function requires valid API credentials to be logged in. Use the Connect-LM #> Function Remove-LMNetscanGroup { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -56,13 +56,13 @@ Function Remove-LMNetscanGroup { $Id = $LookupResult } - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -76,11 +76,11 @@ Function Remove-LMNetscanGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMOpsNote.ps1 b/Public/Remove-LMOpsNote.ps1 index 475a1c2..e737a5a 100644 --- a/Public/Remove-LMOpsNote.ps1 +++ b/Public/Remove-LMOpsNote.ps1 @@ -21,7 +21,7 @@ Returns an object with the ID and a success message if the OpsNote is successful #> Function Remove-LMOpsNote { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [String]$Id @@ -45,11 +45,11 @@ Function Remove-LMOpsNote { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMPropertysource.ps1 b/Public/Remove-LMPropertysource.ps1 index e23164c..98ea80a 100644 --- a/Public/Remove-LMPropertysource.ps1 +++ b/Public/Remove-LMPropertysource.ps1 @@ -29,7 +29,7 @@ System.Management.Automation.PSCustomObject. The function returns an object with #> Function Remove-LMPropertysource { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -39,8 +39,8 @@ Function Remove-LMPropertysource { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -57,13 +57,13 @@ Function Remove-LMPropertysource { #Build header and uri $ResourcePath = "/setting/propertyrules/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -74,11 +74,11 @@ Function Remove-LMPropertysource { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -96,5 +96,5 @@ Function Remove-LMPropertysource { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMReport.ps1 b/Public/Remove-LMReport.ps1 index 06f9411..a0edbe5 100644 --- a/Public/Remove-LMReport.ps1 +++ b/Public/Remove-LMReport.ps1 @@ -30,7 +30,7 @@ This function requires a valid API authentication and authorization. Use Connect #> Function Remove-LMReport { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -53,13 +53,13 @@ Function Remove-LMReport { $Id = $LookupResult } - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -73,11 +73,11 @@ Function Remove-LMReport { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMReportGroup.ps1 b/Public/Remove-LMReportGroup.ps1 index 4772225..f7d6f92 100644 --- a/Public/Remove-LMReportGroup.ps1 +++ b/Public/Remove-LMReportGroup.ps1 @@ -27,7 +27,7 @@ System.Management.Automation.PSCustomObject. Returns an object with the removed #> Function Remove-LMReportGroup { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -50,13 +50,13 @@ Function Remove-LMReportGroup { $Id = $LookupResult } - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -70,11 +70,11 @@ Function Remove-LMReportGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMRole.ps1 b/Public/Remove-LMRole.ps1 index 732981d..ac14116 100644 --- a/Public/Remove-LMRole.ps1 +++ b/Public/Remove-LMRole.ps1 @@ -30,7 +30,7 @@ This function requires a valid API authentication and authorization. Use Connect #> Function Remove-LMRole { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -56,13 +56,13 @@ Function Remove-LMRole { #Build header and uri $ResourcePath = "/setting/roles/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -74,11 +74,11 @@ Function Remove-LMRole { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMSDT.ps1 b/Public/Remove-LMSDT.ps1 index a2422c5..4ba9160 100644 --- a/Public/Remove-LMSDT.ps1 +++ b/Public/Remove-LMSDT.ps1 @@ -1,6 +1,6 @@ Function Remove-LMSDT { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [String]$Id @@ -24,11 +24,11 @@ Function Remove-LMSDT { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMTopologysource.ps1 b/Public/Remove-LMTopologysource.ps1 index 3677d04..9134b8c 100644 --- a/Public/Remove-LMTopologysource.ps1 +++ b/Public/Remove-LMTopologysource.ps1 @@ -1,6 +1,6 @@ Function Remove-LMTopologysource { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -10,8 +10,8 @@ Function Remove-LMTopologysource { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -28,13 +28,13 @@ Function Remove-LMTopologysource { #Build header and uri $ResourcePath = "/setting/topologysources/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -45,11 +45,11 @@ Function Remove-LMTopologysource { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -67,5 +67,5 @@ Function Remove-LMTopologysource { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMUnmonitoredDevice.ps1 b/Public/Remove-LMUnmonitoredDevice.ps1 index c8c675d..9b117ab 100644 --- a/Public/Remove-LMUnmonitoredDevice.ps1 +++ b/Public/Remove-LMUnmonitoredDevice.ps1 @@ -1,6 +1,6 @@ Function Remove-LMUnmonitoredDevice { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id')] [String[]]$Ids @@ -26,7 +26,7 @@ Function Remove-LMUnmonitoredDevice { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.UnmonitoredDevice" ) diff --git a/Public/Remove-LMUser.ps1 b/Public/Remove-LMUser.ps1 index af1ddc4..954bb91 100644 --- a/Public/Remove-LMUser.ps1 +++ b/Public/Remove-LMUser.ps1 @@ -1,6 +1,6 @@ Function Remove-LMUser { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -26,13 +26,13 @@ Function Remove-LMUser { #Build header and uri $ResourcePath = "/setting/admins/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.username)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -44,11 +44,11 @@ Function Remove-LMUser { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Remove-LMWebsite.ps1 b/Public/Remove-LMWebsite.ps1 index 7d49d06..e8a1894 100644 --- a/Public/Remove-LMWebsite.ps1 +++ b/Public/Remove-LMWebsite.ps1 @@ -1,6 +1,6 @@ Function Remove-LMWebsite { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -10,8 +10,8 @@ Function Remove-LMWebsite { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -27,13 +27,13 @@ Function Remove-LMWebsite { #Build header and uri $ResourcePath = "/website/websites/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -44,11 +44,11 @@ Function Remove-LMWebsite { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } @@ -66,5 +66,5 @@ Function Remove-LMWebsite { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Remove-LMWebsiteGroup.ps1 b/Public/Remove-LMWebsiteGroup.ps1 index f77fae7..7cb5674 100644 --- a/Public/Remove-LMWebsiteGroup.ps1 +++ b/Public/Remove-LMWebsiteGroup.ps1 @@ -1,6 +1,6 @@ Function Remove-LMWebsiteGroup { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$Id, @@ -32,13 +32,13 @@ Function Remove-LMWebsiteGroup { $ResourcePath = "/website/groups/$Id" $QueryParams = "?deleteChildren=$deleteChildren" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } @@ -49,11 +49,11 @@ Function Remove-LMWebsiteGroup { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] $Result = [PSCustomObject]@{ - Id = $Id + Id = $Id Message = "Successfully removed ($Message)" } diff --git a/Public/Send-LMPushMetric.ps1 b/Public/Send-LMPushMetric.ps1 index e2c541f..820ce6e 100644 --- a/Public/Send-LMPushMetric.ps1 +++ b/Public/Send-LMPushMetric.ps1 @@ -78,7 +78,7 @@ Function Send-LMPushMetric { If ($Script:LMAuth.Valid) { $QueryParams = $null - If($NewResourceHostName){ + If ($NewResourceHostName) { $QueryParams = "?create=true" } @@ -88,15 +88,15 @@ Function Send-LMPushMetric { Try { $Data = @{ - resourceName = $NewResourceHostName - resourceDescription = $NewResourceDescription - resourceIds = $ResourceIds - resourceProperties = $ResourceProperties - dataSourceId = $DatasourceId - dataSource = ($DatasourceName -replace '[#\\;=]', '_') - dataSourceDisplayName = ($DatasourceDisplayName -replace '[#\\;=]', '_') - dataSourceGroup = $DatasourceGroup - instances = $Instances + resourceName = $NewResourceHostName + resourceDescription = $NewResourceDescription + resourceIds = $ResourceIds + resourceProperties = $ResourceProperties + dataSourceId = $DatasourceId + dataSource = ($DatasourceName -replace '[#\\;=]', '_') + dataSourceDisplayName = ($DatasourceDisplayName -replace '[#\\;=]', '_') + dataSourceGroup = $DatasourceGroup + instances = $Instances } diff --git a/Public/Set-LMAPIToken.ps1 b/Public/Set-LMAPIToken.ps1 index 7ac413a..044301f 100644 --- a/Public/Set-LMAPIToken.ps1 +++ b/Public/Set-LMAPIToken.ps1 @@ -1,6 +1,6 @@ Function Set-LMAPIToken { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [Int]$AdminId, @@ -18,8 +18,8 @@ Function Set-LMAPIToken { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -35,10 +35,10 @@ Function Set-LMAPIToken { #Build header and uri $ResourcePath = "/setting/admins/$AdminId/apitokens/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | AccessId: $($PSItem.accessId)| AdminName:$($PSItem.adminName)" } - Else{ + Else { $Message = "Id: $Id" } @@ -80,5 +80,5 @@ Function Set-LMAPIToken { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMAppliesToFunction.ps1 b/Public/Set-LMAppliesToFunction.ps1 index 74d6494..a852727 100644 --- a/Public/Set-LMAppliesToFunction.ps1 +++ b/Public/Set-LMAppliesToFunction.ps1 @@ -1,13 +1,13 @@ Function Set-LMAppliesToFunction { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Name')] [String]$Name, [String]$NewName, - [Parameter(Mandatory, ParameterSetName = 'Id',ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [String]$Id, [String]$Description, @@ -31,18 +31,18 @@ Function Set-LMAppliesToFunction { #Build header and uri $ResourcePath = "/setting/functions/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - Else{ + Else { $Message = "Id: $Id" } Try { $Data = @{ - name = $NewName - description = $Description - code = $AppliesTo + name = $NewName + description = $Description + code = $AppliesTo } #Remove empty keys so we dont overwrite them @@ -56,7 +56,7 @@ Function Set-LMAppliesToFunction { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "PATCH" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.AppliesToFunction" ) diff --git a/Public/Set-LMCollector.ps1 b/Public/Set-LMCollector.ps1 index f79bc61..dcff40d 100644 --- a/Public/Set-LMCollector.ps1 +++ b/Public/Set-LMCollector.ps1 @@ -1,6 +1,6 @@ Function Set-LMCollector { - [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] @@ -54,13 +54,13 @@ Function Set-LMCollector { #Build header and uri $ResourcePath = "/setting/collector/collectors/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.hostname) | Description: $($PSItem.description)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name)" } - Else{ + Else { $Message = "Id: $Id" } diff --git a/Public/Set-LMCollectorConfig.ps1 b/Public/Set-LMCollectorConfig.ps1 index 1a5c9e1..e5d9209 100644 --- a/Public/Set-LMCollectorConfig.ps1 +++ b/Public/Set-LMCollectorConfig.ps1 @@ -1,6 +1,6 @@ Function Set-LMCollectorConfig { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(ParameterSetName = 'Id-Conf', ValueFromPipelineByPropertyName)] @@ -13,7 +13,7 @@ Function Set-LMCollectorConfig { [Parameter(ParameterSetName = 'Id-Conf')] [Parameter(ParameterSetName = 'Name-Conf')] - [ValidateSet("nano","small", "medium", "large", "extra_large", "double_extra_large")] + [ValidateSet("nano", "small", "medium", "large", "extra_large", "double_extra_large")] [String]$CollectorSize, [Parameter(ParameterSetName = 'Id-Conf')] @@ -105,15 +105,15 @@ Function Set-LMCollectorConfig { $ConfigArray = $Config.Split([Environment]::NewLine) [int[]]$Index = [Linq.Enumerable]::Range(0, $ConfigArray.Count).Where({ param($i) $ConfigArray[$i] -match $ConfLine }) - If(($Index | Measure-Object).Count -eq 1){ + If (($Index | Measure-Object).Count -eq 1) { Write-LMHost "[INFO]: Updating config parameter $ConfLine to value $Value." - $ConfigArray[$Index[0]]="$ConfLine=$Value" + $ConfigArray[$Index[0]] = "$ConfLine=$Value" } - Else{ - Write-LMHost "[WARN]: Multiple matches found for config parameter $ConfLine, skipping processing." -ForegroundColor Yellow + Else { + Write-LMHost "[WARN]: Multiple matches found for config parameter $ConfLine, skipping processing." -ForegroundColor Yellow } - Return ([string]::Join([Environment]::NewLine,$ConfigArray)) + Return ([string]::Join([Environment]::NewLine, $ConfigArray)) } If ($Script:LMAuth.Valid) { @@ -127,67 +127,67 @@ Function Set-LMCollectorConfig { $Id = $LookupResult } - If($PSCmdlet.ParameterSetName -like "*Snippet*"){ + If ($PSCmdlet.ParameterSetName -like "*Snippet*") { $CollectorConfData = (Get-LMCollector -Id $Id).collectorConf - If($CollectorConfData){ + If ($CollectorConfData) { $SnippetArray = [System.Collections.ArrayList]@() $cmdName = $MyInvocation.InvocationName $paramList = (Get-Command -Name $cmdName).Parameters foreach ( $key in $paramList.Keys ) { $value = (Get-Variable $key -ErrorAction SilentlyContinue).Value if ( ($value -or $value -eq 0) -and ($key -ne "Id" -and $key -ne "Name" -and $key -ne "WaitForRestart") ) { - $SnippetArray.Add(@{$key = $value}) | Out-Null + $SnippetArray.Add(@{$key = $value }) | Out-Null } } - Foreach ($Key in $SnippetArray.Keys){ - $CollectorConfData = Switch($Key){ - "SnmpThreadPool" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.snmp.threadpool" -Value $SnippetArray.$Key} - "SnmpPduTimeout" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "snmp.pdu.timeout" -Value $SnippetArray.$Key} - "ScriptThreadPool" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.script.threadpool" -Value $SnippetArray.$Key} - "ScriptTimeout" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.script.timeout" -Value $SnippetArray.$Key} - "BatchScriptThreadPool" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.batchscript.threadpool" -Value $SnippetArray.$Key} - "BatchScriptTimeout" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.batchscript.timeout" -Value $SnippetArray.$Key} - "PowerShellSPSEProcessCountMin" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "powershell.spse.process.count.min" -Value $SnippetArray.$Key} - "PowerShellSPSEProcessCountMax" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "powershell.spse.process.count.max" -Value $SnippetArray.$Key} - "NetflowEnable" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.enable" -Value $SnippetArray.$Key} - "NbarEnable" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.nbar.enabled" -Value $SnippetArray.$Key} - "NetflowPorts" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.ports" -Value $SnippetArray.$Key} - "SflowPorts" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.sflow.ports" -Value $SnippetArray.$Key} - "LMLogsSyslogEnable" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "lmlogs.syslog.enabled" -Value $SnippetArray.$Key} - "LMLogsSyslogHostnameFormat" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "lmlogs.syslog.hostname.format" -Value $SnippetArray.$Key} - "LMLogsSyslogPropertyName" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "lmlogs.syslog.property.name" -Value $SnippetArray.$Key} - default {$CollectorConfData} + Foreach ($Key in $SnippetArray.Keys) { + $CollectorConfData = Switch ($Key) { + "SnmpThreadPool" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.snmp.threadpool" -Value $SnippetArray.$Key } + "SnmpPduTimeout" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "snmp.pdu.timeout" -Value $SnippetArray.$Key } + "ScriptThreadPool" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.script.threadpool" -Value $SnippetArray.$Key } + "ScriptTimeout" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.script.timeout" -Value $SnippetArray.$Key } + "BatchScriptThreadPool" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.batchscript.threadpool" -Value $SnippetArray.$Key } + "BatchScriptTimeout" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "collector.batchscript.timeout" -Value $SnippetArray.$Key } + "PowerShellSPSEProcessCountMin" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "powershell.spse.process.count.min" -Value $SnippetArray.$Key } + "PowerShellSPSEProcessCountMax" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "powershell.spse.process.count.max" -Value $SnippetArray.$Key } + "NetflowEnable" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.enable" -Value $SnippetArray.$Key } + "NbarEnable" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.nbar.enabled" -Value $SnippetArray.$Key } + "NetflowPorts" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.ports" -Value $SnippetArray.$Key } + "SflowPorts" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "netflow.sflow.ports" -Value $SnippetArray.$Key } + "LMLogsSyslogEnable" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "lmlogs.syslog.enabled" -Value $SnippetArray.$Key } + "LMLogsSyslogHostnameFormat" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "lmlogs.syslog.hostname.format" -Value $SnippetArray.$Key } + "LMLogsSyslogPropertyName" { Process-CollectorConfig -Config $CollectorConfData -ConfLine "lmlogs.syslog.property.name" -Value $SnippetArray.$Key } + default { $CollectorConfData } } } } } - Else{ + Else { $CollectorConfData = $CollectorConf } #Build header and uri $ResourcePath = "/setting/collector/collectors/$Id/services/restart" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.hostname) | Description: $($PSItem.description)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name)" } - Else{ + Else { $Message = "Id: $Id" } Try { $Data = @{ - collectorSize = $CollectorSize - collectorConf = $CollectorConfData - sbproxyConf = $SbproxyConf - watchdogConf = $WatchdogConf - websiteConf = $WebsiteConf - wrapperConf = $WrapperConf + collectorSize = $CollectorSize + collectorConf = $CollectorConfData + sbproxyConf = $SbproxyConf + watchdogConf = $WatchdogConf + websiteConf = $WebsiteConf + wrapperConf = $WrapperConf } @@ -197,7 +197,7 @@ Function Set-LMCollectorConfig { $Data = ($Data | ConvertTo-Json) If ($PSCmdlet.ShouldProcess($Message, "Set Collector Config ")) { - Write-LMHost "[WARN]: This command will restart the targeted collector on update of the configuration" -ForegroundColor Yellow + Write-LMHost "[WARN]: This command will restart the targeted collector on update of the configuration" -ForegroundColor Yellow $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath @@ -206,28 +206,28 @@ Function Set-LMCollectorConfig { #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data - If($WaitForRestart){ + If ($WaitForRestart) { $JobStarted = $false $Tries = 0 - While(!$JobStarted -or $Tries -eq 5){ + While (!$JobStarted -or $Tries -eq 5) { #Build header and uri $ResourcePath = "/setting/collector/collectors/$Id/services/restart/$Response" $Headers = New-LMHeader -Auth $Script:LMAuth -Method "GET" -ResourcePath $ResourcePath $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath $SubmitResponse = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] - If($SubmitResponse.errorMessage -eq "The task is still running"){ + If ($SubmitResponse.errorMessage -eq "The task is still running") { Write-LMHost "[INFO]: The task is still running..." Start-Sleep -Seconds 2 $Tries++ } - Else{ + Else { $JobStarted = $true } } Return "Job status code: $($SubmitResponse.jobStatus), Job message: $($SubmitResponse.jobErrmsg)" } - Else{ + Else { Return "Successfully submitted restart request(jobID:$Response) with updated configurations. Collector will restart once the request has been picked up." } } diff --git a/Public/Set-LMCollectorGroup.ps1 b/Public/Set-LMCollectorGroup.ps1 index 146a4c4..7c399fc 100644 --- a/Public/Set-LMCollectorGroup.ps1 +++ b/Public/Set-LMCollectorGroup.ps1 @@ -1,6 +1,6 @@ Function Set-LMCollectorGroup { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] @@ -44,24 +44,24 @@ Function Set-LMCollectorGroup { #Build header and uri $ResourcePath = "/setting/collector/groups/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | Description: $($PSItem.description)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name)" } - Else{ + Else { $Message = "Id: $Id" } Try { $Data = @{ - description = $Description - name = $NewName - collectorGroupId = $CollectorGroupId - customProperties = $customProperties - autoBalance = $AutoBalance - autoBalanceInstanceCountThreshold = $AutoBalanceInstanceCountThreshold + description = $Description + name = $NewName + collectorGroupId = $CollectorGroupId + customProperties = $customProperties + autoBalance = $AutoBalance + autoBalanceInstanceCountThreshold = $AutoBalanceInstanceCountThreshold } diff --git a/Public/Set-LMConfigsource.ps1 b/Public/Set-LMConfigsource.ps1 index 0c16291..b5198fe 100644 --- a/Public/Set-LMConfigsource.ps1 +++ b/Public/Set-LMConfigsource.ps1 @@ -1,6 +1,6 @@ Function Set-LMConfigsource { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [String]$Id, @@ -18,7 +18,7 @@ Function Set-LMConfigsource { [String]$TechNotes, - [ValidateSet("3600","14400","28800","86400")] + [ValidateSet("3600", "14400", "28800", "86400")] [String]$PollingIntervalInSeconds, #In Seconds [PSCustomObject]$ConfigChecks #Should be the full datapoints object from the output of Get-LMDatasource @@ -41,25 +41,25 @@ Function Set-LMConfigsource { #Build header and uri $ResourcePath = "/setting/configsources/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } Try { $Data = @{ - name = $NewName - displayName = $DisplayName - description = $Description - appliesTo = $appliesTo - technology = $TechNotes - collectInterval = $PollingIntervalInSeconds - configChecks = $ConfigChecks + name = $NewName + displayName = $DisplayName + description = $Description + appliesTo = $appliesTo + technology = $TechNotes + collectInterval = $PollingIntervalInSeconds + configChecks = $ConfigChecks } #Remove empty keys so we dont overwrite them diff --git a/Public/Set-LMDatasource.ps1 b/Public/Set-LMDatasource.ps1 index 6ff87ce..c48645c 100644 --- a/Public/Set-LMDatasource.ps1 +++ b/Public/Set-LMDatasource.ps1 @@ -1,6 +1,6 @@ Function Set-LMDatasource { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [String]$Id, @@ -40,25 +40,25 @@ Function Set-LMDatasource { #Build header and uri $ResourcePath = "/setting/datasources/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } Try { $Data = @{ - name = $NewName - displayName = $DisplayName - description = $Description - appliesTo = $appliesTo - technology = $TechNotes - collectInterval = $PollingIntervalInSeconds - dataPoints = $Datapoints + name = $NewName + displayName = $DisplayName + description = $Description + appliesTo = $appliesTo + technology = $TechNotes + collectInterval = $PollingIntervalInSeconds + dataPoints = $Datapoints } #Remove empty keys so we dont overwrite them diff --git a/Public/Set-LMDevice.ps1 b/Public/Set-LMDevice.ps1 index 26f5fff..b13aa5c 100644 --- a/Public/Set-LMDevice.ps1 +++ b/Public/Set-LMDevice.ps1 @@ -1,6 +1,6 @@ Function Set-LMDevice { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [String]$Id, @@ -64,13 +64,13 @@ Function Set-LMDevice { #Build header and uri $ResourcePath = "/device/devices/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name" } - Else{ + Else { $Message = "Id: $Id" } diff --git a/Public/Set-LMDeviceDatasourceInstance.ps1 b/Public/Set-LMDeviceDatasourceInstance.ps1 index 03dd662..1a08ad4 100644 --- a/Public/Set-LMDeviceDatasourceInstance.ps1 +++ b/Public/Set-LMDeviceDatasourceInstance.ps1 @@ -1,6 +1,6 @@ Function Set-LMDeviceDatasourceInstance { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [String]$DisplayName, @@ -40,8 +40,8 @@ Function Set-LMDeviceDatasourceInstance { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -74,13 +74,13 @@ Function Set-LMDeviceDatasourceInstance { #Build header and uri $ResourcePath = "/device/devices/$DeviceId/devicedatasources/$HdsId/instances/$instanceId" - If($PSItem){ + If ($PSItem) { $Message = "deviceDisplayName: $($PSItem.deviceDisplayName) | instanceId: $($PSItem.id) | instanceName: $($PSItem.name)" } - ElseIf($DeviceName){ + ElseIf ($DeviceName) { $Message = "deviceDisplayName: $DeviceName | instanceId: $InstanceId" } - Else{ + Else { $Message = "instanceId: $InstanceId | deviceId: $DeviceId" } @@ -124,5 +124,5 @@ Function Set-LMDeviceDatasourceInstance { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 b/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 index dd5431f..de131a5 100644 --- a/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 +++ b/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 @@ -1,6 +1,6 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { - [CmdletBinding(SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] @@ -47,8 +47,8 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { [Int]$AlertForNoData ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -72,14 +72,14 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { #Lookup HdsiId If ($DatasourceName) { - $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName" }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } $HdsiId = $LookupResult } - Else{ - $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id + Else { + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName" }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } @@ -88,14 +88,14 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { #Lookup HdsiId If ($DatapointName) { - $LookupResult = (Get-LMDeviceDatasourceInstanceAlertSetting -DatasourceName $DatasourceName -Id $Id -InstanceName $InstanceName | Where-Object { $_.dataPointName -eq $DatapointName}).Id + $LookupResult = (Get-LMDeviceDatasourceInstanceAlertSetting -DatasourceName $DatasourceName -Id $Id -InstanceName $InstanceName | Where-Object { $_.dataPointName -eq $DatapointName }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } $DatapointId = $LookupResult } - Else{ - $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -Id $Id -InstanceName $InstanceName | Where-Object { $_.dataPointName -eq $DatapointName}).Id + Else { + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -Id $Id -InstanceName $InstanceName | Where-Object { $_.dataPointName -eq $DatapointName }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { return } @@ -109,13 +109,13 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { Try { $Data = @{ - disableAlerting = $DisableAlerting - alertExprNote = $AlertExpressionNote - alertExpr = $AlertExpression - alertClearTransitionInterval = $AlertClearTransitionInterval - alertClearInterval = $AlertClearTransitionInterval - alertTransitionInterval = $AlertTransitionInterval - alertForNoData = $AlertForNoData + disableAlerting = $DisableAlerting + alertExprNote = $AlertExpressionNote + alertExpr = $AlertExpression + alertClearTransitionInterval = $AlertClearTransitionInterval + alertClearInterval = $AlertClearTransitionInterval + alertTransitionInterval = $AlertTransitionInterval + alertForNoData = $AlertForNoData } #Remove empty keys so we dont overwrite them @@ -145,5 +145,5 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMDeviceGroup.ps1 b/Public/Set-LMDeviceGroup.ps1 index 50003d2..270b95e 100644 --- a/Public/Set-LMDeviceGroup.ps1 +++ b/Public/Set-LMDeviceGroup.ps1 @@ -1,6 +1,6 @@ Function Set-LMDeviceGroup { - [CmdletBinding(DefaultParameterSetName = "Id-ParentGroupId",SupportsShouldProcess,ConfirmImpact='None')] + [CmdletBinding(DefaultParameterSetName = "Id-ParentGroupId", SupportsShouldProcess, ConfirmImpact = 'None')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id-ParentGroupId', ValueFromPipelineByPropertyName)] [Parameter(Mandatory, ParameterSetName = 'Id-ParentGroupName')] @@ -67,13 +67,13 @@ Function Set-LMDeviceGroup { #Build header and uri $ResourcePath = "/device/groups/$Id" - If($PSItem){ + If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | Path: $($PSItem.fullPath)" } - ElseIf($Name){ + ElseIf ($Name) { $Message = "Id: $Id | Name: $Name)" } - Else{ + Else { $Message = "Id: $Id" } diff --git a/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 b/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 index f6ee721..5aaf579 100644 --- a/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 +++ b/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 @@ -43,8 +43,8 @@ Function Set-LMDeviceGroupDatasourceAlertSetting { ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -68,7 +68,7 @@ Function Set-LMDeviceGroupDatasourceAlertSetting { #Lookup DatapointId If ($DatapointName) { - $LookupResult = (Get-LMDeviceGroupDatasourceAlertSetting -Id $Id -DatasourceId $DatasourceId | Where-Object {$_.dataPointName -eq $DatapointName}).dataPointId + $LookupResult = (Get-LMDeviceGroupDatasourceAlertSetting -Id $Id -DatasourceId $DatasourceId | Where-Object { $_.dataPointName -eq $DatapointName }).dataPointId If (Test-LookupResult -Result $LookupResult -LookupString $DatapointName) { return } @@ -80,14 +80,14 @@ Function Set-LMDeviceGroupDatasourceAlertSetting { Try { $dpConfig = @{ - disableAlerting = $DisableAlerting - dataPointId = $DatapointId - dataPointName = $DatapointName - alertExprNote = $AlertExpressionNote - alertExpr = $AlertExpression - alertClearTransitionInterval = $AlertClearTransitionInterval - alertTransitionInterval = $AlertTransitionInterval - alertForNoData = $AlertForNoData + disableAlerting = $DisableAlerting + dataPointId = $DatapointId + dataPointName = $DatapointName + alertExprNote = $AlertExpressionNote + alertExpr = $AlertExpression + alertClearTransitionInterval = $AlertClearTransitionInterval + alertTransitionInterval = $AlertTransitionInterval + alertForNoData = $AlertForNoData } @@ -120,5 +120,5 @@ Function Set-LMDeviceGroupDatasourceAlertSetting { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMDeviceProperty.ps1 b/Public/Set-LMDeviceProperty.ps1 index 0fc5035..6d94c9f 100644 --- a/Public/Set-LMDeviceProperty.ps1 +++ b/Public/Set-LMDeviceProperty.ps1 @@ -15,8 +15,8 @@ Function Set-LMDeviceProperty { [String]$PropertyValue ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -59,5 +59,5 @@ Function Set-LMDeviceProperty { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMNetscanGroup.ps1 b/Public/Set-LMNetscanGroup.ps1 index 06eb514..f68cfcb 100644 --- a/Public/Set-LMNetscanGroup.ps1 +++ b/Public/Set-LMNetscanGroup.ps1 @@ -33,8 +33,8 @@ Function Set-LMNetscanGroup { Try { $Data = @{ - description = $Description - name = $NewName + description = $Description + name = $NewName } diff --git a/Public/Set-LMNewUserMessage.ps1 b/Public/Set-LMNewUserMessage.ps1 index 89da343..ce2a5fe 100644 --- a/Public/Set-LMNewUserMessage.ps1 +++ b/Public/Set-LMNewUserMessage.ps1 @@ -20,8 +20,8 @@ Function Set-LMNewUserMessage { Try { $Data = @{ - messageBody = $MessageBody - messageSubject = $MessageSubject + messageBody = $MessageBody + messageSubject = $MessageSubject } #Remove empty keys so we dont overwrite them diff --git a/Public/Set-LMOpsNote.ps1 b/Public/Set-LMOpsNote.ps1 index 4031a2f..f046244 100644 --- a/Public/Set-LMOpsNote.ps1 +++ b/Public/Set-LMOpsNote.ps1 @@ -20,43 +20,43 @@ Function Set-LMOpsNote { [String[]]$DeviceIds ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { - If($NoteDate){ + If ($NoteDate) { $Epoch = Get-Date -Date "01/01/1970" [int64]$NoteDate = (New-TimeSpan -Start $Epoch -End $NoteDate.ToUniversalTime()).TotalSeconds } $Scope = @() - If($ResourceIds -or $WebsiteIds -or $DeviceGroupIds){ - Foreach($deviceId in $DeviceIds){ + If ($ResourceIds -or $WebsiteIds -or $DeviceGroupIds) { + Foreach ($deviceId in $DeviceIds) { $Scope += [PSCustomObject]@{ - type = "device" - groupId = "0" + type = "device" + groupId = "0" deviceId = $deviceId } } - Foreach($websiteId in $WebsiteIds){ + Foreach ($websiteId in $WebsiteIds) { $Scope += [PSCustomObject]@{ - type = "website" - groupId = "0" + type = "website" + groupId = "0" websiteId = $websiteId } } - Foreach($groupId in $DeviceGroupIds){ + Foreach ($groupId in $DeviceGroupIds) { $Scope += @{ - type = "deviceGroup" + type = "deviceGroup" groupId = $groupId } } } $TagList = @() - Foreach($tag in $Tags){ - $TagList += @{name = $tag} + Foreach ($tag in $Tags) { + $TagList += @{name = $tag } } @@ -74,7 +74,7 @@ Function Set-LMOpsNote { #Remove empty keys so we dont overwrite them @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } - If($ClearTags){ + If ($ClearTags) { $Data.tags = @() } @@ -101,5 +101,5 @@ Function Set-LMOpsNote { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMPortalInfo.ps1 b/Public/Set-LMPortalInfo.ps1 index 395dce4..6757fb7 100644 --- a/Public/Set-LMPortalInfo.ps1 +++ b/Public/Set-LMPortalInfo.ps1 @@ -16,13 +16,13 @@ Function Set-LMPortalInfo { [String]$CompanyDisplayName, - [ValidateSet(30,60,120,240,480,1440,10080,43200)] + [ValidateSet(30, 60, 120, 240, 480, 1440, 10080, 43200)] [Nullable[Int]]$UserSessionTimeoutInMin ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -30,19 +30,19 @@ Function Set-LMPortalInfo { $ResourcePath = "/setting/companySetting" $Data = @{ - whiteList = $Whitelist - sessionTimeoutInSeconds = $UserSessionTimeoutInMin * 60 - requireTwoFA = $RequireTwoFA - alertTotalIncludeInAck = $IncludeACKinAlertTotals - alertTotalIncludeInSdt = $IncludeSDTinAlertTotals - companyDisplayName = $CompanyDisplayName - enableRemoteSession = $EnableRemoteSession + whiteList = $Whitelist + sessionTimeoutInSeconds = $UserSessionTimeoutInMin * 60 + requireTwoFA = $RequireTwoFA + alertTotalIncludeInAck = $IncludeACKinAlertTotals + alertTotalIncludeInSdt = $IncludeSDTinAlertTotals + companyDisplayName = $CompanyDisplayName + enableRemoteSession = $EnableRemoteSession } #Remove empty keys so we dont overwrite them @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } - If($ClearWhitelist){ + If ($ClearWhitelist) { $Data.whitelist = "" } @@ -70,5 +70,5 @@ Function Set-LMPortalInfo { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMPropertysource.ps1 b/Public/Set-LMPropertysource.ps1 index 8dcc031..42d5dad 100644 --- a/Public/Set-LMPropertysource.ps1 +++ b/Public/Set-LMPropertysource.ps1 @@ -43,13 +43,13 @@ Function Set-LMPropertysource { Try { $Data = @{ - name = $NewName - description = $Description - appliesTo = $appliesTo - technology = $TechNotes - group = $Group - groovyScript = $Script - scriptType = $ScriptType + name = $NewName + description = $Description + appliesTo = $appliesTo + technology = $TechNotes + group = $Group + groovyScript = $Script + scriptType = $ScriptType } #Remove empty keys so we dont overwrite them diff --git a/Public/Set-LMPushModuleDeviceProperty.ps1 b/Public/Set-LMPushModuleDeviceProperty.ps1 index c8ab07e..047a838 100644 --- a/Public/Set-LMPushModuleDeviceProperty.ps1 +++ b/Public/Set-LMPushModuleDeviceProperty.ps1 @@ -15,8 +15,8 @@ Function Set-LMPushModuleDeviceProperty { [String]$PropertyValue ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -33,8 +33,8 @@ Function Set-LMPushModuleDeviceProperty { Try { $Data = @{ - resourceIds = @{"system.deviceid"=$Id} - resourceProperties = @{$PropertyName=$PropertyValue} + resourceIds = @{"system.deviceid" = $Id } + resourceProperties = @{$PropertyName = $PropertyValue } } $Data = ($Data | ConvertTo-Json) @@ -60,5 +60,5 @@ Function Set-LMPushModuleDeviceProperty { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMPushModuleInstanceProperty.ps1 b/Public/Set-LMPushModuleInstanceProperty.ps1 index 13580c1..29a45c4 100644 --- a/Public/Set-LMPushModuleInstanceProperty.ps1 +++ b/Public/Set-LMPushModuleInstanceProperty.ps1 @@ -21,8 +21,8 @@ Function Set-LMPushModuleInstanceProperty { [String]$PropertyValue ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -39,10 +39,10 @@ Function Set-LMPushModuleInstanceProperty { Try { $Data = @{ - resourceIds = @{"system.deviceid"=$DeviceId} - instanceName = $InstanceName - dataSource = $DataSourceName - instanceProperties = @{$PropertyName=$PropertyValue} + resourceIds = @{"system.deviceid" = $DeviceId } + instanceName = $InstanceName + dataSource = $DataSourceName + instanceProperties = @{$PropertyName = $PropertyValue } } $Data = ($Data | ConvertTo-Json) @@ -68,5 +68,5 @@ Function Set-LMPushModuleInstanceProperty { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Public/Set-LMReportGroup.ps1 b/Public/Set-LMReportGroup.ps1 index bbf44e9..c06ccc6 100644 --- a/Public/Set-LMReportGroup.ps1 +++ b/Public/Set-LMReportGroup.ps1 @@ -32,8 +32,8 @@ Function Set-LMReportGroup { Try { $Data = @{ - description = $Description - name = $NewName + description = $Description + name = $NewName } diff --git a/Public/Set-LMRole.ps1 b/Public/Set-LMRole.ps1 index 938a480..4f8144b 100644 --- a/Public/Set-LMRole.ps1 +++ b/Public/Set-LMRole.ps1 @@ -2,12 +2,12 @@ Function Set-LMRole { [CmdletBinding(DefaultParameterSetName = 'Default')] Param ( - [Parameter(Mandatory,ParameterSetName = 'Id-Custom', ValueFromPipelineByPropertyName)] - [Parameter(Mandatory,ParameterSetName = 'Id-Default', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = 'Id-Custom', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = 'Id-Default', ValueFromPipelineByPropertyName)] [String]$Id, - [Parameter(Mandatory,ParameterSetName = 'Name-Custom')] - [Parameter(Mandatory,ParameterSetName = 'Name-Default')] + [Parameter(Mandatory, ParameterSetName = 'Name-Custom')] + [Parameter(Mandatory, ParameterSetName = 'Name-Default')] [String]$Name, [Parameter(ParameterSetName = 'Id-Custom')] @@ -54,47 +54,47 @@ Function Set-LMRole { [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$DashboardsPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$ResourcePermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view","manage","commit","publish","none")] + [ValidateSet("view", "manage", "commit", "publish", "none")] [String]$LMXToolBoxPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view","install","none")] + [ValidateSet("view", "install", "none")] [String]$LMXPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$LogsPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$WebsitesPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$SavedMapsPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none")] + [ValidateSet("view", "manage", "none")] [String]$ReportsPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] [Parameter(ParameterSetName = 'Id-Default')] - [ValidateSet("view", "manage","none","manage-collectors","view-collectors")] + [ValidateSet("view", "manage", "none", "manage-collectors", "view-collectors")] [String]$SettingsPermission = "none", [Parameter(ParameterSetName = 'Name-Default')] @@ -129,8 +129,8 @@ Function Set-LMRole { [Parameter(ParameterSetName = 'Id-Default')] [Switch]$EnableRemoteSessionForResources, - [Parameter(Mandatory,ParameterSetName = 'Name-Custom')] - [Parameter(Mandatory,ParameterSetName = 'Id-Custom')] + [Parameter(Mandatory, ParameterSetName = 'Name-Custom')] + [Parameter(Mandatory, ParameterSetName = 'Id-Custom')] [PSCustomObject]$CustomPrivilegesObject ) @@ -150,197 +150,197 @@ Function Set-LMRole { $ResourcePath = "/setting/roles/$Id" $Privileges = @() - If(!$CustomPrivilegesObject){ + If (!$CustomPrivilegesObject) { - If($ViewTraces){ + If ($ViewTraces) { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "tracesManageTab" - operation = "read" + objectId = "*" + objectName = "*" + objectType = "tracesManageTab" + operation = "read" subOperation = "" } } - If($EnableRemoteSessionForResources){ + If ($EnableRemoteSessionForResources) { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "remoteSession" - operation = "write" + objectId = "*" + objectName = "*" + objectType = "remoteSession" + operation = "write" subOperation = "" } } - If($AllowedToViewMapsTab){ + If ($AllowedToViewMapsTab) { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "resourceMapTab" - operation = "read" + objectId = "*" + objectName = "*" + objectType = "resourceMapTab" + operation = "read" subOperation = "" } } - If($AllowWidgetSharing){ + If ($AllowWidgetSharing) { $Privileges += [PSCustomObject]@{ - objectId = "sharingwidget" - objectName = "sharingwidget" - objectType = "dashboard_group" - operation = "write" + objectId = "sharingwidget" + objectName = "sharingwidget" + objectType = "dashboard_group" + operation = "write" subOperation = "" } } - If($CreatePrivateDashboards){ + If ($CreatePrivateDashboards) { $Privileges += [PSCustomObject]@{ - objectId = "private" - objectName = "private" - objectType = "dashboard_group" - operation = "write" + objectId = "private" + objectName = "private" + objectType = "dashboard_group" + operation = "write" subOperation = "" } } - If($LMXToolBoxPermission){ + If ($LMXToolBoxPermission) { $Privileges += [PSCustomObject]@{ - objectId = "allinstalledmodules" + objectId = "allinstalledmodules" objectName = "All installed modules" objectType = "module" - operation = $LMXToolBoxPermission + operation = $LMXToolBoxPermission } } - If($LMXPermission){ + If ($LMXPermission) { $Privileges += [PSCustomObject]@{ - objectId = "All exchange modules" + objectId = "All exchange modules" objectName = "private" objectType = "module" - operation = $LMXPermission + operation = $LMXPermission } } - If($ViewSupport){ + If ($ViewSupport) { $Privileges += [PSCustomObject]@{ - objectId = "chat" - objectName = "help" - objectType = "help" - operation = "write" + objectId = "chat" + objectName = "help" + objectType = "help" + operation = "write" subOperation = "" } $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "help" - objectType = "help" - operation = "read" + objectId = "*" + objectName = "help" + objectType = "help" + operation = "read" subOperation = "" } } - If($ConfigTabRequiresManagePermission){ + If ($ConfigTabRequiresManagePermission) { $Privileges += [PSCustomObject]@{ - objectId = "" - objectName = "configNeedDeviceManagePermission" - objectType = "configNeedDeviceManagePermission" - operation = "write" + objectId = "" + objectName = "configNeedDeviceManagePermission" + objectType = "configNeedDeviceManagePermission" + operation = "write" subOperation = "" } } - If($AllowedToManageResourceDashboards){ + If ($AllowedToManageResourceDashboards) { $Privileges += [PSCustomObject]@{ - objectId = "" - objectName = "deviceDashboard" - objectType = "deviceDashboard" - operation = "write" + objectId = "" + objectName = "deviceDashboard" + objectType = "deviceDashboard" + operation = "write" subOperation = "" } } - If($DashboardsPermission -ne "none"){ + If ($DashboardsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "dashboard_group" - operation = If($DashboardsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "dashboard_group" + operation = If ($DashboardsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($ResourcePermission -ne "none"){ + If ($ResourcePermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "host_group" - operation = If($ResourcePermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "host_group" + operation = If ($ResourcePermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($LogsPermission -ne "none"){ + If ($LogsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "logs" - operation = If($LogsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "logs" + operation = If ($LogsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($WebsitesPermission -ne "none"){ + If ($WebsitesPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "website_group" - operation = If($WebsitesPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "website_group" + operation = If ($WebsitesPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($SavedMapsPermission -ne "none"){ + If ($SavedMapsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "map" - operation = If($SavedMapsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "map" + operation = If ($SavedMapsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($ReportsPermission -ne "none"){ + If ($ReportsPermission -ne "none") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "report_group" - operation = If($ReportsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "report_group" + operation = If ($ReportsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - If($SettingsPermission -ne "none"){ - If($SettingsPermission -ne "manage-collectors" -and $SettingsPermission -ne "view-collectors"){ + If ($SettingsPermission -ne "none") { + If ($SettingsPermission -ne "manage-collectors" -and $SettingsPermission -ne "view-collectors") { $Privileges += [PSCustomObject]@{ - objectId = "*" - objectName = "*" - objectType = "setting" - operation = If($SettingsPermission -eq "manage"){"write"}Else{"read"} + objectId = "*" + objectName = "*" + objectType = "setting" + operation = If ($SettingsPermission -eq "manage") { "write" }Else { "read" } subOperation = "" } $Privileges += [PSCustomObject]@{ - objectId = "useraccess.*" - objectName = "useraccess.*" - objectType = "setting" - operation = If($ResourcePermission -eq "manage"){"write"}Else{"read"} + objectId = "useraccess.*" + objectName = "useraccess.*" + objectType = "setting" + operation = If ($ResourcePermission -eq "manage") { "write" }Else { "read" } subOperation = "" } } - Else{ + Else { $Privileges += [PSCustomObject]@{ - objectId = "collectorgroup.*" + objectId = "collectorgroup.*" objectName = "Collectors" objectType = "setting" - operation = If($SettingsPermission -eq "manage-collectors"){"write"}Else{"read"} + operation = If ($SettingsPermission -eq "manage-collectors") { "write" }Else { "read" } } } } @@ -352,10 +352,10 @@ Function Set-LMRole { customHelpURL = $CustomHelpURL description = $Description name = $NewName - requireEULA = If($RequireEULA.IsPresent){"true"}Else{""} + requireEULA = If ($RequireEULA.IsPresent) { "true" }Else { "" } roleGroupId = $RoleGroupId - twoFARequired = If($TwoFARequired.IsPresent){"true"}Else{""} - privileges = If($CustomPrivilegesObject){$CustomPrivilegesObject}Else{$Privileges} + twoFARequired = If ($TwoFARequired.IsPresent) { "true" }Else { "" } + privileges = If ($CustomPrivilegesObject) { $CustomPrivilegesObject }Else { $Privileges } } #Remove empty keys so we dont overwrite them @@ -367,7 +367,7 @@ Function Set-LMRole { Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data - #Issue request + #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "PATCH" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.Role" ) diff --git a/Public/Set-LMSDT.ps1 b/Public/Set-LMSDT.ps1 index 2ec3b94..befb38d 100644 --- a/Public/Set-LMSDT.ps1 +++ b/Public/Set-LMSDT.ps1 @@ -1,6 +1,6 @@ Function Set-LMSDT { - [CmdletBinding(DefaultParameterSetName="OneTime")] + [CmdletBinding(DefaultParameterSetName = "OneTime")] Param ( [Parameter(Mandatory)] [String]$Id, @@ -34,11 +34,11 @@ Function Set-LMSDT { [Nullable[Int]]$EndMinute, [Parameter(ParameterSetName = 'Recurring')] - [ValidateSet("Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday","Sunday")] + [ValidateSet("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")] [String]$WeekDay, [Parameter(ParameterSetName = 'Recurring')] - [ValidateSet("First", "Second", "Third","Fourth","Last")] + [ValidateSet("First", "Second", "Third", "Fourth", "Last")] [String]$WeekOfMonth, [Parameter(ParameterSetName = 'Recurring')] @@ -54,22 +54,22 @@ Function Set-LMSDT { Try { $Data = @{} - $Data.Add('comment',$Comment) - $Data.Add('hour',$StartHour) - $Data.Add('minute',$StartMinute) - $Data.Add('endHour',$EndHour) - $Data.Add('endMinute',$EndMinute) - $Data.Add('weekDay',$WeekDay) - $Data.Add('monthDay',$DayOfMonth) - $Data.Add('weekOfMonth',$WeekOfMonth) - - If($StartDate){ + $Data.Add('comment', $Comment) + $Data.Add('hour', $StartHour) + $Data.Add('minute', $StartMinute) + $Data.Add('endHour', $EndHour) + $Data.Add('endMinute', $EndMinute) + $Data.Add('weekDay', $WeekDay) + $Data.Add('monthDay', $DayOfMonth) + $Data.Add('weekOfMonth', $WeekOfMonth) + + If ($StartDate) { $StartDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $StartDate.ToUniversalTime()).TotalMilliseconds - $Data.Add('startDateTime',[math]::Round($StartDateTime)) + $Data.Add('startDateTime', [math]::Round($StartDateTime)) } - If($EndDate){ + If ($EndDate) { $EndDateTime = (New-TimeSpan -Start (Get-Date "01/01/1970") -End $EndDate.ToUniversalTime()).TotalMilliseconds - $Data.Add('endDateTime',[math]::Round($EndDateTime)) + $Data.Add('endDateTime', [math]::Round($EndDateTime)) } #Remove empty keys so we dont overwrite them diff --git a/Public/Set-LMTopologysource.ps1 b/Public/Set-LMTopologysource.ps1 index 9d837a4..41d137a 100644 --- a/Public/Set-LMTopologysource.ps1 +++ b/Public/Set-LMTopologysource.ps1 @@ -16,7 +16,7 @@ Function Set-LMTopologysource { [String]$TechNotes, - [ValidateSet("1800","3600","7200","21600")] + [ValidateSet("1800", "3600", "7200", "21600")] [Nullable[Int]]$PollingIntervalInSeconds, [String]$Group, @@ -45,7 +45,7 @@ Function Set-LMTopologysource { $ResourcePath = "/setting/topologysources/$Id" $collectorAttribute = $null - If($ScriptType -or $Script){ + If ($ScriptType -or $Script) { $collectorAttribute = @{ groovyScript = $Script scriptType = $ScriptType @@ -57,13 +57,13 @@ Function Set-LMTopologysource { Try { $Data = @{ - name = $NewName - description = $Description - appliesTo = $appliesTo - technology = $TechNotes - group = $Group - collectInterval = $PollingIntervalInSeconds - collectorAttribute = $collectorAttribute + name = $NewName + description = $Description + appliesTo = $appliesTo + technology = $TechNotes + group = $Group + collectInterval = $PollingIntervalInSeconds + collectorAttribute = $collectorAttribute } #Remove empty keys so we dont overwrite them diff --git a/Public/Set-LMUnmonitoredDevice.ps1 b/Public/Set-LMUnmonitoredDevice.ps1 index 331261e..c51e0ce 100644 --- a/Public/Set-LMUnmonitoredDevice.ps1 +++ b/Public/Set-LMUnmonitoredDevice.ps1 @@ -24,9 +24,9 @@ Function Set-LMUnmonitoredDevice { Try { $Data = @{ collectorId = $CollectorId - description = $Description - deviceGroupId = $DeviceGroupId - missingDeviceIds = $Ids + description = $Description + deviceGroupId = $DeviceGroupId + missingDeviceIds = $Ids } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMWebsite.ps1 b/Public/Set-LMWebsite.ps1 index ebf1779..9839c80 100644 --- a/Public/Set-LMWebsite.ps1 +++ b/Public/Set-LMWebsite.ps1 @@ -1,6 +1,6 @@ Function Set-LMWebsite { - [CmdletBinding(DefaultParameterSetName="Website")] + [CmdletBinding(DefaultParameterSetName = "Website")] Param ( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [String]$Id, @@ -19,38 +19,38 @@ Function Set-LMWebsite { [Nullable[boolean]]$UseDefaultLocationSetting, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[boolean]]$TriggerSSLStatusAlert, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[boolean]]$TriggerSSLExpirationAlert, [String]$GroupId, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [String]$PingAddress, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [String]$WebsiteDomain, [ValidateSet("http", "https")] - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [String]$HttpType, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [String[]]$SSLAlertThresholds, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [ValidateSet(5, 10, 15, 20, 30, 60)] [Nullable[Int]]$PingCount, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [Nullable[Int]]$PingTimeout, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [Nullable[Int]]$PageLoadAlertTimeInMS, - [Parameter(ParameterSetName="Ping")] + [Parameter(ParameterSetName = "Ping")] [ValidateSet(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)] [Nullable[Int]]$PingPercentNotReceived, @@ -71,12 +71,12 @@ Function Set-LMWebsite { [ValidateSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)] [Nullable[Int]]$PollingInterval, - [Parameter(ParameterSetName="Website")] + [Parameter(ParameterSetName = "Website")] [String[]]$WebsiteSteps ) - Begin{} - Process{ + Begin {} + Process { #Check if we are logged in and have valid api creds If ($Script:LMAuth.Valid) { @@ -161,5 +161,5 @@ Function Set-LMWebsite { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." } } - End{} + End {} } diff --git a/Tests/LMDevice.Tests.ps1 b/Tests/LMDevice.Tests.ps1 index 3749aed..877f962 100644 --- a/Tests/LMDevice.Tests.ps1 +++ b/Tests/LMDevice.Tests.ps1 @@ -64,7 +64,7 @@ Describe 'Device Testing New/Get/Set/Remove' { Describe 'Set-LMDevice' { It 'When given a set of parameters, returns an updated resource with matching values' { - { $Device = Set-LMDevice -Id $Script:NewDevice.Id -Description "Updated" -Properties @{"test"="123";"test2"="456"} -ErrorAction Stop + { $Device = Set-LMDevice -Id $Script:NewDevice.Id -Description "Updated" -Properties @{"test" = "123"; "test2" = "456" } -ErrorAction Stop $Device.Description | Should -Be "Updated" $Device.CustomProperties.name.IndexOf("test") | Should -Not -BeExactly -1 $Device.CustomProperties.name.IndexOf("test2") | Should -Not -BeExactly -1 @@ -74,7 +74,7 @@ Describe 'Device Testing New/Get/Set/Remove' { Describe 'Remove-LMDevice' { It 'When given an id, remove the device from logic monitor' { - { Remove-LMDevice -Id $Script:NewDevice.Id -HardDelete $true -Confirm:$false -ErrorAction Stop} | Should -Not -Throw + { Remove-LMDevice -Id $Script:NewDevice.Id -HardDelete $true -Confirm:$false -ErrorAction Stop } | Should -Not -Throw } } diff --git a/Tests/LMDeviceGroup.Tests.ps1 b/Tests/LMDeviceGroup.Tests.ps1 index ecfdeae..60ea492 100644 --- a/Tests/LMDeviceGroup.Tests.ps1 +++ b/Tests/LMDeviceGroup.Tests.ps1 @@ -6,7 +6,7 @@ Describe 'DeviceGroup Testing New/Get/Set/Remove' { Describe 'New-LMDeviceGroup' { It 'When given mandatory parameters, returns a created group with matching values' { - $Script:NewDeviceGroup = New-LMDeviceGroup -Name "DeviceGroup.Build.Test" -Description "Testing123" -ParentGroupId 1 -Properties @{"testing"="123"} -DisableAlerting $true -AppliesTo "false()" + $Script:NewDeviceGroup = New-LMDeviceGroup -Name "DeviceGroup.Build.Test" -Description "Testing123" -ParentGroupId 1 -Properties @{"testing" = "123" } -DisableAlerting $true -AppliesTo "false()" $Script:NewDeviceGroup | Should -Not -BeNullOrEmpty $Script:NewDeviceGroup.Description | Should -Be "Testing123" $Script:NewDeviceGroup.DisableAlerting | Should -Be $true @@ -36,7 +36,7 @@ Describe 'DeviceGroup Testing New/Get/Set/Remove' { Describe 'Set-LMDeviceGroup' { It 'When given a set of parameters, returns an updated group with matching values' { - { $DeviceGroup = Set-LMDeviceGroup -Id $Script:NewDeviceGroup.Id -Description "Updated" -Properties @{"test"="123";"test2"="456"} -ErrorAction Stop + { $DeviceGroup = Set-LMDeviceGroup -Id $Script:NewDeviceGroup.Id -Description "Updated" -Properties @{"test" = "123"; "test2" = "456" } -ErrorAction Stop $DeviceGroup.Description | Should -Be "Updated" $DeviceGroup.CustomProperties.name.IndexOf("test") | Should -Not -BeExactly -1 $DeviceGroup.CustomProperties.name.IndexOf("test2") | Should -Not -BeExactly -1 diff --git a/Tests/LMOpsNotes.Tests.ps1 b/Tests/LMOpsNotes.Tests.ps1 index 67f43d3..9e6bbc4 100644 --- a/Tests/LMOpsNotes.Tests.ps1 +++ b/Tests/LMOpsNotes.Tests.ps1 @@ -23,7 +23,7 @@ Describe 'OpsNotes Testing New/Get/Set/Remove' { } It 'When given an id should return that opsnote' { $Retry = 0 - While(!$OpsNote -or $Retry -eq 5){ + While (!$OpsNote -or $Retry -eq 5) { $OpsNote = Get-LMOpsNote -Id $Script:NewOpsNote.Id -ErrorAction SilentlyContinue $Retry++ } @@ -31,7 +31,7 @@ Describe 'OpsNotes Testing New/Get/Set/Remove' { } It 'When given a name should return specified opsnote matching that tag value' { $Retry = 0 - While(!$OpsNote -or $Retry -eq 5){ + While (!$OpsNote -or $Retry -eq 5) { $OpsNote = Get-LMOpsNote -Tag $Script:NewOpsNote.Tags.name -ErrorAction SilentlyContinue $Retry++ } @@ -39,8 +39,8 @@ Describe 'OpsNotes Testing New/Get/Set/Remove' { } It 'When given a wildcard name should return all opsnotes matching that wildcard value' { $Retry = 0 - While(!$OpsNote -or $Retry -eq 5){ - $OpsNote = Get-LMOpsNote -Tag "$(($Script:NewOpsNote.Tags.name.Split(".")[0]))*" -ErrorAction SilentlyContinue + While (!$OpsNote -or $Retry -eq 5) { + $OpsNote = Get-LMOpsNote -Tag "$(($Script:NewOpsNote.Tags.name.Split(".")[0]))*" -ErrorAction SilentlyContinue $Retry++ } ($OpsNote | Measure-Object).Count | Should -BeGreaterThan 0 diff --git a/Tests/LMUser-Role.Tests.ps1 b/Tests/LMUser-Role.Tests.ps1 index 6faa456..5c2a983 100644 --- a/Tests/LMUser-Role.Tests.ps1 +++ b/Tests/LMUser-Role.Tests.ps1 @@ -88,7 +88,7 @@ Describe 'User & Role Testing New/Get/Set/Remove' { Describe 'Remove-LMRole' { It 'When given an id, remove the role from logic monitor' { - { Remove-LMRole -Id $Script:NewRole.Id -ErrorAction Stop -Confirm:$false } | Should -Not -Throw + { Remove-LMRole -Id $Script:NewRole.Id -ErrorAction Stop -Confirm:$false } | Should -Not -Throw } } diff --git a/Tests/LMWebsite.Tests.ps1 b/Tests/LMWebsite.Tests.ps1 index a14728b..0170e1a 100644 --- a/Tests/LMWebsite.Tests.ps1 +++ b/Tests/LMWebsite.Tests.ps1 @@ -6,7 +6,7 @@ Describe 'Website Testing New/Get/Set/Remove' { Describe 'New-LMWebsite' { It 'When given mandatory parameters, returns a created website with matching values' { - $Script:NewWebsite = New-LMWebsite -Name "Website.Build.Test" -Webcheck -WebsiteDomain "example.com" -Description "BuildTest" -Properties @{"testprop"="BuildTest"} + $Script:NewWebsite = New-LMWebsite -Name "Website.Build.Test" -Webcheck -WebsiteDomain "example.com" -Description "BuildTest" -Properties @{"testprop" = "BuildTest" } $Script:NewWebsite | Should -Not -BeNullOrEmpty $Script:NewWebsite.Description | Should -BeExactly "BuildTest" $Script:NewWebsite.properties.name.IndexOf("testprop") | Should -Not -BeExactly -1 @@ -15,7 +15,7 @@ Describe 'Website Testing New/Get/Set/Remove' { Describe 'Get-LMWebsiteProperty' { It 'When given mandatory parameters, returns a specified property' { - $WebsiteProp = Get-LMWebsiteProperty -Id $Script:NewWebsite.Id | Where-Object {$_.name -eq "testprop"} + $WebsiteProp = Get-LMWebsiteProperty -Id $Script:NewWebsite.Id | Where-Object { $_.name -eq "testprop" } $WebsiteProp | Should -Not -BeNullOrEmpty } } @@ -45,7 +45,7 @@ Describe 'Website Testing New/Get/Set/Remove' { Describe 'Set-LMWebsite' { It 'When given a set of parameters, returns an updated website with matching values' { - { $Device = Set-LMWebsite -Id $Script:NewWebsite.Id -Description "Updated" -Properties @{"test"="123";"test2"="456"} -ErrorAction Stop + { $Device = Set-LMWebsite -Id $Script:NewWebsite.Id -Description "Updated" -Properties @{"test" = "123"; "test2" = "456" } -ErrorAction Stop $Device.Description | Should -Be "Updated" $Device.Properties.name.IndexOf("test") | Should -Not -BeExactly -1 $Device.Properties.name.IndexOf("test2") | Should -Not -BeExactly -1 diff --git a/Tests/LMWebsiteGroup.Tests.ps1 b/Tests/LMWebsiteGroup.Tests.ps1 index ab1ea9e..8b171ee 100644 --- a/Tests/LMWebsiteGroup.Tests.ps1 +++ b/Tests/LMWebsiteGroup.Tests.ps1 @@ -6,7 +6,7 @@ Describe 'WebsiteGroup Testing New/Get/Set/Remove' { Describe 'New-LMWebsiteGroup' { It 'When given mandatory parameters, returns a created group with matching values' { - $Script:NewWebsiteGroup = New-LMWebsiteGroup -Name "WebsiteGroup.Build.Test" -Description "Testing123" -ParentGroupId 1 -Properties @{"testing"="123"} -DisableAlerting $true + $Script:NewWebsiteGroup = New-LMWebsiteGroup -Name "WebsiteGroup.Build.Test" -Description "Testing123" -ParentGroupId 1 -Properties @{"testing" = "123" } -DisableAlerting $true $Script:NewWebsiteGroup | Should -Not -BeNullOrEmpty $Script:NewWebsiteGroup.Description | Should -Be "Testing123" $Script:NewWebsiteGroup.DisableAlerting | Should -Be $true @@ -35,7 +35,7 @@ Describe 'WebsiteGroup Testing New/Get/Set/Remove' { Describe 'Set-LMWebsiteGroup' { It 'When given a set of parameters, returns an updated group with matching values' { - { $WebsiteGroup = Set-LMWebsiteGroup -Id $Script:NewWebsiteGroup.Id -Description "Updated" -Properties @{"test"="123";"test2"="456"} -ErrorAction Stop + { $WebsiteGroup = Set-LMWebsiteGroup -Id $Script:NewWebsiteGroup.Id -Description "Updated" -Properties @{"test" = "123"; "test2" = "456" } -ErrorAction Stop $WebsiteGroup.Description | Should -Be "Updated" $WebsiteGroup.Properties.name.IndexOf("test") | Should -Not -BeExactly -1 $WebsiteGroup.Properties.name.IndexOf("test2") | Should -Not -BeExactly -1 From 58c33fc540b79875d42bb1061bb0a8e97be64c3a Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:52:27 -0400 Subject: [PATCH 2/6] Additional file formatting --- Build.ps1 | 16 ++++++++-------- EXAMPLES.md | 4 ++-- Private/Add-ObjectTypeInfo.ps1 | 10 +++++----- Private/Format-LMFilter-v1.ps1 | 4 ++-- Private/Format-LMFilter.ps1 | 2 +- Private/New-LMHeader.ps1 | 4 ++-- Private/Resolve-LMDebugInfo.ps1 | 2 +- Private/Resolve-LMException.ps1 | 2 -- Private/Test-LookupResult.ps1 | 2 +- Private/Update-LogicMonitorModule.ps1 | 4 ++-- Private/Write-LMHost.ps1 | 4 ++-- Public/Connect-LMAccount.ps1 | 14 +++++++------- Public/Get-LMAlert.ps1 | 2 +- Public/Get-LMAuditLogs.ps1 | 2 +- Public/Get-LMDeviceConfigSourceData.ps1 | 2 +- Public/Get-LMIntegrationLogs.ps1 | 2 +- Public/Invoke-LMActiveDiscovery.ps1 | 4 ++-- Public/Invoke-LMCollectorDebugCommand.ps1 | 2 +- Public/New-LMAPIUser.ps1 | 2 +- Public/New-LMCollector.ps1 | 2 +- Public/New-LMCollectorGroup.ps1 | 2 +- Public/New-LMDevice.ps1 | 2 +- Public/New-LMDeviceDatasourceInstance.ps1 | 2 +- Public/New-LMDeviceDatasourceInstanceGroup.ps1 | 2 +- Public/New-LMDeviceDatasourceInstanceSDT.ps1 | 2 +- Public/New-LMDeviceDatasourceSDT.ps1 | 2 +- Public/New-LMDeviceGroupSDT.ps1 | 2 +- Public/New-LMDeviceSDT.ps1 | 2 +- Public/New-LMEnhancedNetscan.ps1 | 2 +- Public/New-LMNetscan.ps1 | 2 +- Public/New-LMNetscanGroup.ps1 | 2 +- Public/New-LMOpsNote.ps1 | 2 +- Public/New-LMReportGroup.ps1 | 2 +- Public/New-LMRole.ps1 | 2 +- Public/New-LMUser.ps1 | 4 ++-- Public/New-LMWebsite.ps1 | 2 +- Public/Remove-LMAPIToken.ps1 | 2 +- Public/Remove-LMAppliesToFunction.ps1 | 2 +- Public/Remove-LMCachedAccount.ps1 | 2 +- Public/Remove-LMCollectorGroup.ps1 | 2 +- Public/Remove-LMConfigsource.ps1 | 2 +- Public/Remove-LMDashboard.ps1 | 2 +- Public/Remove-LMDashboardGroup.ps1 | 2 +- Public/Remove-LMDashboardWidget.ps1 | 2 +- Public/Remove-LMDevice.ps1 | 2 +- Public/Remove-LMDeviceDatasourceInstance.ps1 | 2 +- Public/Remove-LMDeviceGroup.ps1 | 2 +- Public/Remove-LMNetscan.ps1 | 2 +- Public/Remove-LMNetscanGroup.ps1 | 2 +- Public/Remove-LMPropertysource.ps1 | 2 +- Public/Remove-LMReport.ps1 | 2 +- Public/Remove-LMReportGroup.ps1 | 2 +- Public/Remove-LMRole.ps1 | 2 +- Public/Remove-LMTopologysource.ps1 | 2 +- Public/Remove-LMUnmonitoredDevice.ps1 | 2 +- Public/Remove-LMUser.ps1 | 2 +- Public/Remove-LMWebsite.ps1 | 2 +- Public/Remove-LMWebsiteGroup.ps1 | 2 +- Public/Send-LMLogMessage.ps1 | 2 +- Public/Send-LMPushMetric.ps1 | 2 +- Public/Set-LMAPIToken.ps1 | 2 +- Public/Set-LMAppliesToFunction.ps1 | 2 +- Public/Set-LMCollector.ps1 | 4 ++-- Public/Set-LMCollectorConfig.ps1 | 12 ++++++------ Public/Set-LMCollectorGroup.ps1 | 4 ++-- Public/Set-LMConfigsource.ps1 | 4 ++-- Public/Set-LMDatasource.ps1 | 4 ++-- Public/Set-LMDevice.ps1 | 4 ++-- Public/Set-LMDeviceDatasourceInstance.ps1 | 4 ++-- ...et-LMDeviceDatasourceInstanceAlertSetting.ps1 | 2 +- Public/Set-LMDeviceGroup.ps1 | 4 ++-- .../Set-LMDeviceGroupDatasourceAlertSetting.ps1 | 2 +- Public/Set-LMNetScan.ps1 | 2 +- Public/Set-LMNetscanGroup.ps1 | 2 +- Public/Set-LMNewUserMessage.ps1 | 2 +- Public/Set-LMOpsNote.ps1 | 2 +- Public/Set-LMPortalInfo.ps1 | 2 +- Public/Set-LMPropertysource.ps1 | 2 +- Public/Set-LMReportGroup.ps1 | 2 +- Public/Set-LMRole.ps1 | 2 +- Public/Set-LMSDT.ps1 | 2 +- Public/Set-LMTopologysource.ps1 | 4 ++-- Public/Set-LMUser.ps1 | 4 ++-- Public/Set-LMWebsite.ps1 | 2 +- Public/Set-LMWebsiteGroup.ps1 | 2 +- 85 files changed, 122 insertions(+), 124 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index f7b2e98..76e7185 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -6,35 +6,35 @@ $manifestPath = "./Logic.Monitor.psd1" $publicFuncFolderPath = './Public' $ps1xmlFiles = Get-ChildItem -Path ./ -Filter *.ps1xml -foreach ($ps1xml in $ps1xmlFiles) { +Foreach ($ps1xml in $ps1xmlFiles) { [xml]$xml = Get-Content -Path $ps1xml.FullName $null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Format.xsd') $null = $xml.Schemas.Add($null, 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Types.xsd') - $xml.Validate( { throw "File '$($ps1xml.Name)' schema error: $($_.Message)" }) + $xml.Validate( { Throw "File '$($ps1xml.Name)' schema error: $($_.Message)" }) } -if (!(Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' })) { +If (!(Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' })) { Install-PackageProvider -Name NuGet -Force | Out-Null } Import-PackageProvider -Name NuGet -Force | Out-Null -if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') { +If ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted } -if (!(Get-Module Microsoft.PowerShell.SecretManagement -ListAvailable)) { +If (!(Get-Module Microsoft.PowerShell.SecretManagement -ListAvailable)) { Install-Module Microsoft.PowerShell.SecretManagement -Force -Confirm:$false } -if (!(Get-Module Microsoft.PowerShell.SecretStore -ListAvailable)) { +If (!(Get-Module Microsoft.PowerShell.SecretStore -ListAvailable)) { Install-Module Microsoft.PowerShell.SecretStore -Force -Confirm:$false } $manifestContent = (Get-Content -Path $manifestPath -Raw) -replace '', $buildVersion -if ((Test-Path -Path $publicFuncFolderPath) -and ($publicFunctionNames = Get-ChildItem -Path $publicFuncFolderPath -Filter '*.ps1' | Select-Object -ExpandProperty BaseName)) { +If ((Test-Path -Path $publicFuncFolderPath) -and ($publicFunctionNames = Get-ChildItem -Path $publicFuncFolderPath -Filter '*.ps1' | Select-Object -ExpandProperty BaseName)) { $funcStrings = "'$($publicFunctionNames -join "','")'" } -else { +Else { $funcStrings = $null } diff --git a/EXAMPLES.md b/EXAMPLES.md index 43f1e2b..b05eba4 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -192,7 +192,7 @@ Set-LMDevice -Name "192.168.1.1" -DisplayName $deviceProperty #Method Three #Using Get-LMDeviceGroupDevices to retrieve a list of devices and loop through each and set the sysname value to the displayname $devices = Get-LMDeviceGroupDevices -Name "Cambium Wireless" -foreach ($dev in $devices) { +Foreach ($dev in $devices) { $deviceProperty = ($dev.systemProperties[$dev.systemProperties.name.IndexOf("system.sysname")].value) if($deviceProperty -and $dev.systemProperties.name.IndexOf("system.sysname") -ne -1){ Set-LMDevice -Id $dev.id -DisplayName $deviceProperty @@ -209,7 +209,7 @@ $processedDeviceList = @() $devices = Get-LMDeviceGroupDevices -Id "23" #Loop through each device and check for presence of property -foreach ($dev in $devices) { +Foreach ($dev in $devices) { $propName = "test.prop" $propValue = "1234" $currentPropValue = ($dev.customProperties[$dev.customProperties.name.IndexOf($propName)].value) diff --git a/Private/Add-ObjectTypeInfo.ps1 b/Private/Add-ObjectTypeInfo.ps1 index 72f39da..553433b 100644 --- a/Private/Add-ObjectTypeInfo.ps1 +++ b/Private/Add-ObjectTypeInfo.ps1 @@ -96,7 +96,7 @@ function Add-ObjectTypeInfo { http://blogs.microsoft.co.il/scriptfanatic/2012/04/13/custom-objects-default-display-in-powershell-30/ #> [CmdletBinding()] - param( + Param ( [Parameter( Mandatory = $true, Position = 0, ValueFromPipeline = $true )] @@ -121,17 +121,17 @@ function Add-ObjectTypeInfo { ) Begin { - if ($PSBoundParameters.ContainsKey('DefaultProperties')) { + If ($PSBoundParameters.ContainsKey('DefaultProperties')) { # define a subset of properties $ddps = New-Object System.Management.Automation.PSPropertySet DefaultDisplayPropertySet, $DefaultProperties $PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]$ddps } } Process { - foreach ($Object in $InputObject) { + Foreach ($Object in $InputObject) { switch ($PSBoundParameters.Keys) { 'PropertyToAdd' { - foreach ($Key in $PropertyToAdd.Keys) { + Foreach ($Key in $PropertyToAdd.Keys) { #Add some noteproperties. Slightly faster than Add-Member. $Object.PSObject.Properties.Add( ( New-Object PSNoteProperty($Key, $PropertyToAdd[$Key]) ) ) } @@ -145,7 +145,7 @@ function Add-ObjectTypeInfo { Add-Member -InputObject $Object -MemberType MemberSet -Name PSStandardMembers -Value $PSStandardMembers } } - if ($Passthru) { + If ($Passthru) { $Object } } diff --git a/Private/Format-LMFilter-v1.ps1 b/Private/Format-LMFilter-v1.ps1 index 3ebaa4f..22e0975 100644 --- a/Private/Format-LMFilter-v1.ps1 +++ b/Private/Format-LMFilter-v1.ps1 @@ -24,7 +24,7 @@ System.String. The function returns a string that represents the formatted filter. .NOTES - The function does not throw any errors. If a property in the Filter parameter is not in the PropList parameter, it is simply removed from the filter. + If a property in the Filter parameter is not in the PropList parameter, it is simply removed from the filter. #> Function Format-LMFilter-v1 { [CmdletBinding()] @@ -48,7 +48,7 @@ Function Format-LMFilter-v1 { } #Create filter string from hash table and url encode - foreach ($Key in $($Filter.keys)) { + Foreach ($Key in $($Filter.keys)) { $FilterString += $Key + ":" + "`"$($Filter[$Key])`"" + "," } $FilterString = $FilterString.trimend(',') diff --git a/Private/Format-LMFilter.ps1 b/Private/Format-LMFilter.ps1 index bc78275..d15f390 100644 --- a/Private/Format-LMFilter.ps1 +++ b/Private/Format-LMFilter.ps1 @@ -52,7 +52,7 @@ Function Format-LMFilter { If ($Filter -match '\s+-and\s+') { $FormatedFilter += "," } - ElseIf ($Filter -match '\s+-or\s+') { + Elseif ($Filter -match '\s+-or\s+') { $FormatedFilter += "||" } Else { diff --git a/Private/New-LMHeader.ps1 b/Private/New-LMHeader.ps1 index 621d47f..9437be1 100644 --- a/Private/New-LMHeader.ps1 +++ b/Private/New-LMHeader.ps1 @@ -66,7 +66,7 @@ Function New-LMHeader { $Token = [System.Net.NetworkCredential]::new("", $Auth.BearerToken).Password $Header.Add("Authorization", "Bearer $Token") } - ElseIf ($Auth.Type -eq "SessionSync") { + Elseif ($Auth.Type -eq "SessionSync") { $SessionInfo = Get-LMSession -AccountName $Auth.Portal If ($SessionInfo) { $Header.Add("Cookie", "JSESSIONID=$($SessionInfo.jSessionID)") @@ -74,7 +74,7 @@ Function New-LMHeader { $Header.Add("X-CSRF-Token", "$($SessionInfo.token)") } Else { - throw "Unable to generate header details, ensure you are connected to a portal and try again." + Throw "Unable to generate header details, ensure you are connected to a portal and try again." } } Else { diff --git a/Private/Resolve-LMDebugInfo.ps1 b/Private/Resolve-LMDebugInfo.ps1 index c4ad207..c848986 100644 --- a/Private/Resolve-LMDebugInfo.ps1 +++ b/Private/Resolve-LMDebugInfo.ps1 @@ -34,5 +34,5 @@ Function Resolve-LMDebugInfo { Write-Debug "Bound Parameters: $($Command.BoundParameters.GetEnumerator() | ForEach-Object {"[" + $($_.Key) + ":" + $($_.Value) + "]"})" Write-Debug "Invoked URL: $Url" If ($Payload) { Write-Debug "Request Payload: `n$Payload" } - Write-Debug "Request Headers: $($Headers.GetEnumerator() | ForEach-Object {"[" + $($_.Key) + ":" + $(if ($_.Value.length -gt 25) { $_.Value.substring(0, 25) + "...]" } else { $($_.Value) + "]" })})" + Write-Debug "Request Headers: $($Headers.GetEnumerator() | ForEach-Object {"[" + $($_.Key) + ":" + $(If ($_.Value.length -gt 25) { $_.Value.substring(0, 25) + "...]" } Else { $($_.Value) + "]" })})" } \ No newline at end of file diff --git a/Private/Resolve-LMException.ps1 b/Private/Resolve-LMException.ps1 index 37cc3d0..1055c61 100644 --- a/Private/Resolve-LMException.ps1 +++ b/Private/Resolve-LMException.ps1 @@ -48,7 +48,6 @@ Function Resolve-LMException { [Console]::ForegroundColor = 'red' [Console]::Error.WriteLine("Failed to execute web request($($HttpStatusCode)): $HttpException") [Console]::ResetColor() - #throw "Failed to execute web request($($HttpStatusCode)): $HttpException" } } default { @@ -62,7 +61,6 @@ Function Resolve-LMException { [Console]::ForegroundColor = 'red' [Console]::Error.WriteLine("Failed to execute web request: $LMError") [Console]::ResetColor() - #throw "Failed to execute web request: $LMError" } } } diff --git a/Private/Test-LookupResult.ps1 b/Private/Test-LookupResult.ps1 index c5ef4f3..0b5a713 100644 --- a/Private/Test-LookupResult.ps1 +++ b/Private/Test-LookupResult.ps1 @@ -29,7 +29,7 @@ Function Test-LookupResult { return $true } #If empty stop processing since we have no Id to use - ElseIf (!$Result) { + Elseif (!$Result) { [Console]::ForegroundColor = 'red' [Console]::Error.WriteLine("Unable to find resource for the specified name value: $LookupString. Please check spelling and try again.") [Console]::ResetColor() diff --git a/Private/Update-LogicMonitorModule.ps1 b/Private/Update-LogicMonitorModule.ps1 index 83caa30..615c73d 100644 --- a/Private/Update-LogicMonitorModule.ps1 +++ b/Private/Update-LogicMonitorModule.ps1 @@ -46,7 +46,7 @@ Function Update-LogicMonitorModule { If ($Installed -is [Array]) { $InstalledVersion = $Installed[0].Version } - ElseIf ($Installed.Version) { + Elseif ($Installed.Version) { $InstalledVersion = $Installed.Version } Else { @@ -65,7 +65,7 @@ Function Update-LogicMonitorModule { If ($CheckOnly) { Write-LMHost "[INFO]: You are currently using an outdated version ($InstalledVersion) of $Module, please consider upgrading to the latest version ($OnlineVersion) as soon as possible. Use the -AutoUpdateModule switch next time you connect to auto upgrade to the latest version." -ForegroundColor Yellow } - ElseIf ($UninstallFirst -eq $true) { + Elseif ($UninstallFirst -eq $true) { Write-LMHost "[INFO]: You are currently using an outdated version ($InstalledVersion) of $Module, uninstalling prior Module $Module version $InstalledVersion" -ForegroundColor Yellow Uninstall-Module -Name $Module -Force -Verbose:$False diff --git a/Private/Write-LMHost.ps1 b/Private/Write-LMHost.ps1 index 3cebe02..ac50a1f 100644 --- a/Private/Write-LMHost.ps1 +++ b/Private/Write-LMHost.ps1 @@ -40,10 +40,10 @@ Function Write-LMHost { If ($ForegroundColor -and !$BackgroundColor) { Write-Host $Message -ForegroundColor $ForegroundColor } - ElseIf (!$ForegroundColor -and $BackgroundColor) { + Elseif (!$ForegroundColor -and $BackgroundColor) { Write-Host $Message -BackgroundColor $BackgroundColor } - ElseIf ($ForegroundColor -and $BackgroundColor) { + Elseif ($ForegroundColor -and $BackgroundColor) { Write-Host $Message -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor } Else { diff --git a/Public/Connect-LMAccount.ps1 b/Public/Connect-LMAccount.ps1 index 9d30a7b..0c8aecd 100644 --- a/Public/Connect-LMAccount.ps1 +++ b/Public/Connect-LMAccount.ps1 @@ -177,7 +177,7 @@ Function Connect-LMAccount { If ($Type -eq "LMv1") { [SecureString]$AccessKey = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString } - ElseIf ($Type -eq "Bearer") { + Elseif ($Type -eq "Bearer") { [SecureString]$BearerToken = Get-Secret -Vault "Logic.Monitor" -Name $CachedAccountName -AsPlainText | ConvertTo-SecureString } Else { @@ -202,7 +202,7 @@ Function Connect-LMAccount { [SecureString]$AccessKey = $AccessKey | ConvertTo-SecureString -AsPlainText -Force $Type = "LMv1" } - ElseIf ($PsCmdlet.ParameterSetName -eq "SessionSync") { + Elseif ($PsCmdlet.ParameterSetName -eq "SessionSync") { $Session = Get-LMSession -AccountName $AccountName If ($Session) { $AccessId = $Session.jSessionID #Session Id @@ -210,7 +210,7 @@ Function Connect-LMAccount { $Type = "SessionSync" } Else { - throw "Unable to validate session sync info for: $AccountName" + Throw "Unable to validate session sync info for: $AccountName" } } Else { @@ -240,7 +240,7 @@ Function Connect-LMAccount { If ($AutoUpdateModuleVersion -and !$SkipVersionCheck) { Update-LogicMonitorModule } - ElseIf (!$SkipVersionCheck) { + Elseif (!$SkipVersionCheck) { Update-LogicMonitorModule -CheckOnly } } @@ -271,7 +271,7 @@ Function Connect-LMAccount { Return } Catch { - throw "Unable to validate API token info" + Throw "Unable to validate API token info" } } } @@ -284,14 +284,14 @@ Function Connect-LMAccount { Return } Else { - throw "Unable to verify api token permission levels, ensure api token has rights to view all/select resources or at minimum view access for Account Information" + Throw "Unable to verify api token permission levels, ensure api token has rights to view all/select resources or at minimum view access for Account Information" } } Catch { #Clear credential object from environment Remove-Variable LMAuth -Scope Script -ErrorAction SilentlyContinue - throw "Unable to login to account, please ensure your access info and account name are correct: $($_.Exception.Message)" + Throw "Unable to login to account, please ensure your access info and account name are correct: $($_.Exception.Message)" } Return } diff --git a/Public/Get-LMAlert.ps1 b/Public/Get-LMAlert.ps1 index ef93c51..1567b46 100644 --- a/Public/Get-LMAlert.ps1 +++ b/Public/Get-LMAlert.ps1 @@ -164,7 +164,7 @@ Function Get-LMAlert { $Done = $true Write-LMHost "[WARN]: Reached $QueryLimit record query limitation for this endpoint" -ForegroundColor Yellow } - ElseIf ($Count -ge $Total -and $Total -ge 0) { + Elseif ($Count -ge $Total -and $Total -ge 0) { $Done = $true } } diff --git a/Public/Get-LMAuditLogs.ps1 b/Public/Get-LMAuditLogs.ps1 index 9e5e2c7..d143c9e 100644 --- a/Public/Get-LMAuditLogs.ps1 +++ b/Public/Get-LMAuditLogs.ps1 @@ -125,7 +125,7 @@ Function Get-LMAuditLogs { $Done = $true Write-LMHost "[WARN]: Reached $QueryLimit record query limitation for this endpoint" -ForegroundColor Yellow } - ElseIf ($Count -ge $Total -and $Total -ge 0) { + Elseif ($Count -ge $Total -and $Total -ge 0) { $Done = $true } } diff --git a/Public/Get-LMDeviceConfigSourceData.ps1 b/Public/Get-LMDeviceConfigSourceData.ps1 index 95d88bf..7369aa8 100644 --- a/Public/Get-LMDeviceConfigSourceData.ps1 +++ b/Public/Get-LMDeviceConfigSourceData.ps1 @@ -72,7 +72,7 @@ Function Get-LMDeviceConfigSourceData { $Done = $true Return $Response } - ElseIf ($LatestConfigOnly) { + Elseif ($LatestConfigOnly) { Return $Response.Items } #Check result size and if needed loop again diff --git a/Public/Get-LMIntegrationLogs.ps1 b/Public/Get-LMIntegrationLogs.ps1 index 57a7ca0..7a3a30a 100644 --- a/Public/Get-LMIntegrationLogs.ps1 +++ b/Public/Get-LMIntegrationLogs.ps1 @@ -90,7 +90,7 @@ Function Get-LMIntegrationLogs { $Done = $true Write-LMHost "[WARN]: Reached $QueryLimit record query limitation for this endpoint" -ForegroundColor Yellow } - ElseIf ($Count -ge $Total -and $Total -ge 0) { + Elseif ($Count -ge $Total -and $Total -ge 0) { $Done = $true } } diff --git a/Public/Invoke-LMActiveDiscovery.ps1 b/Public/Invoke-LMActiveDiscovery.ps1 index 6265d75..a25ffbf 100644 --- a/Public/Invoke-LMActiveDiscovery.ps1 +++ b/Public/Invoke-LMActiveDiscovery.ps1 @@ -69,7 +69,7 @@ Function Invoke-LMActiveDiscovery { } $deviceList = $LookupResult } - ElseIf ($Id) { + Elseif ($Id) { $deviceList = $Id } @@ -85,7 +85,7 @@ Function Invoke-LMActiveDiscovery { return } } - ElseIf ($GroupId) { + Elseif ($GroupId) { $deviceList = (Get-LMDeviceGroupDevices -Id $GroupId).Id If (!$deviceList) { Write-Error "Unable to find devices for groupId: $GroupId, please check spelling and try again." diff --git a/Public/Invoke-LMCollectorDebugCommand.ps1 b/Public/Invoke-LMCollectorDebugCommand.ps1 index a04753e..7130480 100644 --- a/Public/Invoke-LMCollectorDebugCommand.ps1 +++ b/Public/Invoke-LMCollectorDebugCommand.ps1 @@ -87,7 +87,7 @@ Function Invoke-LMCollectorDebugCommand { import com.santaba.agent.collector3.CollectorDb; def hostProps = [:]; def instanceProps = [:]; -try { +Try { hostProps = CollectorDb.getInstance().getHost("$CommandHostName").getProperties(); instanceProps["wildvalue"] = "$CommandWildValue"; } diff --git a/Public/New-LMAPIUser.ps1 b/Public/New-LMAPIUser.ps1 index d9f17df..d83c41e 100644 --- a/Public/New-LMAPIUser.ps1 +++ b/Public/New-LMAPIUser.ps1 @@ -95,7 +95,7 @@ Function New-LMAPIUser { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMCollector.ps1 b/Public/New-LMCollector.ps1 index c5455f6..30749ee 100644 --- a/Public/New-LMCollector.ps1 +++ b/Public/New-LMCollector.ps1 @@ -107,7 +107,7 @@ Function New-LMCollector { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMCollectorGroup.ps1 b/Public/New-LMCollectorGroup.ps1 index 33262a0..c3ce1c7 100644 --- a/Public/New-LMCollectorGroup.ps1 +++ b/Public/New-LMCollectorGroup.ps1 @@ -72,7 +72,7 @@ Function New-LMCollectorGroup { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMDevice.ps1 b/Public/New-LMDevice.ps1 index 5e33330..a4edc74 100644 --- a/Public/New-LMDevice.ps1 +++ b/Public/New-LMDevice.ps1 @@ -139,7 +139,7 @@ Function New-LMDevice { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMDeviceDatasourceInstance.ps1 b/Public/New-LMDeviceDatasourceInstance.ps1 index 100a677..7534ff5 100644 --- a/Public/New-LMDeviceDatasourceInstance.ps1 +++ b/Public/New-LMDeviceDatasourceInstance.ps1 @@ -143,7 +143,7 @@ Function New-LMDeviceDatasourceInstance { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMDeviceDatasourceInstanceGroup.ps1 b/Public/New-LMDeviceDatasourceInstanceGroup.ps1 index 7e765e4..3c53dce 100644 --- a/Public/New-LMDeviceDatasourceInstanceGroup.ps1 +++ b/Public/New-LMDeviceDatasourceInstanceGroup.ps1 @@ -97,7 +97,7 @@ Function New-LMDeviceDatasourceInstanceGroup { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMDeviceDatasourceInstanceSDT.ps1 b/Public/New-LMDeviceDatasourceInstanceSDT.ps1 index 5ace878..3b98f66 100644 --- a/Public/New-LMDeviceDatasourceInstanceSDT.ps1 +++ b/Public/New-LMDeviceDatasourceInstanceSDT.ps1 @@ -179,7 +179,7 @@ Function New-LMDeviceDatasourceInstanceSDT { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMDeviceDatasourceSDT.ps1 b/Public/New-LMDeviceDatasourceSDT.ps1 index bba0c39..da41b8e 100644 --- a/Public/New-LMDeviceDatasourceSDT.ps1 +++ b/Public/New-LMDeviceDatasourceSDT.ps1 @@ -174,7 +174,7 @@ Function New-LMDeviceDatasourceSDT { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMDeviceGroupSDT.ps1 b/Public/New-LMDeviceGroupSDT.ps1 index 02b60dc..f677ad0 100644 --- a/Public/New-LMDeviceGroupSDT.ps1 +++ b/Public/New-LMDeviceGroupSDT.ps1 @@ -220,7 +220,7 @@ Function New-LMDeviceGroupSDT { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMDeviceSDT.ps1 b/Public/New-LMDeviceSDT.ps1 index 9e61f3d..6d7bfe7 100644 --- a/Public/New-LMDeviceSDT.ps1 +++ b/Public/New-LMDeviceSDT.ps1 @@ -211,7 +211,7 @@ Function New-LMDeviceSDT { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMEnhancedNetscan.ps1 b/Public/New-LMEnhancedNetscan.ps1 index ffa19a2..40151e4 100644 --- a/Public/New-LMEnhancedNetscan.ps1 +++ b/Public/New-LMEnhancedNetscan.ps1 @@ -151,7 +151,7 @@ Function New-LMEnhancedNetScan { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json -Depth 10) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath diff --git a/Public/New-LMNetscan.ps1 b/Public/New-LMNetscan.ps1 index cef3746..f96e80c 100644 --- a/Public/New-LMNetscan.ps1 +++ b/Public/New-LMNetscan.ps1 @@ -151,7 +151,7 @@ Function New-LMNetScan { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMNetscanGroup.ps1 b/Public/New-LMNetscanGroup.ps1 index 8815a3d..d976084 100644 --- a/Public/New-LMNetscanGroup.ps1 +++ b/Public/New-LMNetscanGroup.ps1 @@ -51,7 +51,7 @@ Function New-LMNetscanGroup { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMOpsNote.ps1 b/Public/New-LMOpsNote.ps1 index 3197522..84ca494 100644 --- a/Public/New-LMOpsNote.ps1 +++ b/Public/New-LMOpsNote.ps1 @@ -101,7 +101,7 @@ Function New-LMOpsNote { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMReportGroup.ps1 b/Public/New-LMReportGroup.ps1 index e261283..25b5fc6 100644 --- a/Public/New-LMReportGroup.ps1 +++ b/Public/New-LMReportGroup.ps1 @@ -55,7 +55,7 @@ Function New-LMReportGroup { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/New-LMRole.ps1 b/Public/New-LMRole.ps1 index 9fe2d76..f3d0632 100644 --- a/Public/New-LMRole.ps1 +++ b/Public/New-LMRole.ps1 @@ -405,7 +405,7 @@ Function New-LMRole { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMUser.ps1 b/Public/New-LMUser.ps1 index 39746e5..503b10e 100644 --- a/Public/New-LMUser.ps1 +++ b/Public/New-LMUser.ps1 @@ -159,7 +159,7 @@ Function New-LMUser { } break } - ElseIf ($ViewPermission.ContainsKey($View)) { + Elseif ($ViewPermission.ContainsKey($View)) { $ViewPermission[$View] = $true } } @@ -197,7 +197,7 @@ Function New-LMUser { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/New-LMWebsite.ps1 b/Public/New-LMWebsite.ps1 index 0516cc4..6ea34e9 100644 --- a/Public/New-LMWebsite.ps1 +++ b/Public/New-LMWebsite.ps1 @@ -290,7 +290,7 @@ Function New-LMWebsite { $Data.testLocation = $TestLocations } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "testLocation" -and $_ -ne "steps" -and $_ -ne "checkpoints") { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "testLocation" -and $_ -ne "steps" -and $_ -ne "checkpoints") { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json -Depth 5) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/Remove-LMAPIToken.ps1 b/Public/Remove-LMAPIToken.ps1 index 0c64d8f..5c5d159 100644 --- a/Public/Remove-LMAPIToken.ps1 +++ b/Public/Remove-LMAPIToken.ps1 @@ -92,7 +92,7 @@ Function Remove-LMAPIToken { } Try { - if ($PSCmdlet.ShouldProcess($Message, "Remove API Token")) { + If ($PSCmdlet.ShouldProcess($Message, "Remove API Token")) { $Headers = New-LMHeader -Auth $Script:LMAuth -Method "DELETE" -ResourcePath $ResourcePath $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath diff --git a/Public/Remove-LMAppliesToFunction.ps1 b/Public/Remove-LMAppliesToFunction.ps1 index 7282050..8a6752f 100644 --- a/Public/Remove-LMAppliesToFunction.ps1 +++ b/Public/Remove-LMAppliesToFunction.ps1 @@ -59,7 +59,7 @@ Function Remove-LMAppliesToFunction { If ($PSItem) { $Message = "Id: $Id | Name:$($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMCachedAccount.ps1 b/Public/Remove-LMCachedAccount.ps1 index f34fd7e..261fb1a 100644 --- a/Public/Remove-LMCachedAccount.ps1 +++ b/Public/Remove-LMCachedAccount.ps1 @@ -37,7 +37,7 @@ Function Remove-LMCachedAccount { Process { If ($RemoveAllEntries) { $CachedAccounts = Get-SecretInfo -Vault Logic.Monitor - if ($PSCmdlet.ShouldProcess("$(($CachedAccounts | Measure-Object).Count) cached account(s)", "Remove All Cached Accounts")) { + If ($PSCmdlet.ShouldProcess("$(($CachedAccounts | Measure-Object).Count) cached account(s)", "Remove All Cached Accounts")) { Foreach ($Account in $CachedAccounts.Name) { Try { Remove-Secret -Name $Account -Vault Logic.Monitor -Confirm:$false -ErrorAction Stop diff --git a/Public/Remove-LMCollectorGroup.ps1 b/Public/Remove-LMCollectorGroup.ps1 index 53a0f9b..e58437f 100644 --- a/Public/Remove-LMCollectorGroup.ps1 +++ b/Public/Remove-LMCollectorGroup.ps1 @@ -56,7 +56,7 @@ Function Remove-LMCollectorGroup { If ($PSItem) { $Message = "Id: $($PSItem.id) | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMConfigsource.ps1 b/Public/Remove-LMConfigsource.ps1 index 67631c4..ca10441 100644 --- a/Public/Remove-LMConfigsource.ps1 +++ b/Public/Remove-LMConfigsource.ps1 @@ -64,7 +64,7 @@ Function Remove-LMConfigsource { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMDashboard.ps1 b/Public/Remove-LMDashboard.ps1 index b25d279..f39670a 100644 --- a/Public/Remove-LMDashboard.ps1 +++ b/Public/Remove-LMDashboard.ps1 @@ -61,7 +61,7 @@ Function Remove-LMDashboard { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMDashboardGroup.ps1 b/Public/Remove-LMDashboardGroup.ps1 index 88bc08b..cc64e96 100644 --- a/Public/Remove-LMDashboardGroup.ps1 +++ b/Public/Remove-LMDashboardGroup.ps1 @@ -53,7 +53,7 @@ Function Remove-LMDashboardGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMDashboardWidget.ps1 b/Public/Remove-LMDashboardWidget.ps1 index e8c4f83..5d3dbbc 100644 --- a/Public/Remove-LMDashboardWidget.ps1 +++ b/Public/Remove-LMDashboardWidget.ps1 @@ -63,7 +63,7 @@ Function Remove-LMDashboardWidget { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMDevice.ps1 b/Public/Remove-LMDevice.ps1 index 165f8ee..7ea218d 100644 --- a/Public/Remove-LMDevice.ps1 +++ b/Public/Remove-LMDevice.ps1 @@ -65,7 +65,7 @@ Function Remove-LMDevice { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMDeviceDatasourceInstance.ps1 b/Public/Remove-LMDeviceDatasourceInstance.ps1 index 18f852d..9cac3b6 100644 --- a/Public/Remove-LMDeviceDatasourceInstance.ps1 +++ b/Public/Remove-LMDeviceDatasourceInstance.ps1 @@ -96,7 +96,7 @@ Function Remove-LMDeviceDatasourceInstance { If ($PSItem) { $Message = "DeviceDisplayName: $($PSItem.deviceDisplayName) | DatasourceName: $($PSItem.name) | WildValue: $($PSItem.wildValue)" } - ElseIf ($DatasourceName -and $DeviceName) { + Elseif ($DatasourceName -and $DeviceName) { $Message = "DeviceName: $DeviceName | DatasourceName: $DatasourceName | WildValue: $WildValue" } Else { diff --git a/Public/Remove-LMDeviceGroup.ps1 b/Public/Remove-LMDeviceGroup.ps1 index 0a89619..0401640 100644 --- a/Public/Remove-LMDeviceGroup.ps1 +++ b/Public/Remove-LMDeviceGroup.ps1 @@ -64,7 +64,7 @@ Function Remove-LMDeviceGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMNetscan.ps1 b/Public/Remove-LMNetscan.ps1 index 8065b0f..af023aa 100644 --- a/Public/Remove-LMNetscan.ps1 +++ b/Public/Remove-LMNetscan.ps1 @@ -59,7 +59,7 @@ Function Remove-LMNetscan { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMNetscanGroup.ps1 b/Public/Remove-LMNetscanGroup.ps1 index 8ee5a59..b032f11 100644 --- a/Public/Remove-LMNetscanGroup.ps1 +++ b/Public/Remove-LMNetscanGroup.ps1 @@ -59,7 +59,7 @@ Function Remove-LMNetscanGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMPropertysource.ps1 b/Public/Remove-LMPropertysource.ps1 index 98ea80a..d533233 100644 --- a/Public/Remove-LMPropertysource.ps1 +++ b/Public/Remove-LMPropertysource.ps1 @@ -60,7 +60,7 @@ Function Remove-LMPropertysource { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMReport.ps1 b/Public/Remove-LMReport.ps1 index a0edbe5..223d992 100644 --- a/Public/Remove-LMReport.ps1 +++ b/Public/Remove-LMReport.ps1 @@ -56,7 +56,7 @@ Function Remove-LMReport { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMReportGroup.ps1 b/Public/Remove-LMReportGroup.ps1 index f7d6f92..2ed1423 100644 --- a/Public/Remove-LMReportGroup.ps1 +++ b/Public/Remove-LMReportGroup.ps1 @@ -53,7 +53,7 @@ Function Remove-LMReportGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMRole.ps1 b/Public/Remove-LMRole.ps1 index ac14116..6f736bd 100644 --- a/Public/Remove-LMRole.ps1 +++ b/Public/Remove-LMRole.ps1 @@ -59,7 +59,7 @@ Function Remove-LMRole { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMTopologysource.ps1 b/Public/Remove-LMTopologysource.ps1 index 9134b8c..89f404d 100644 --- a/Public/Remove-LMTopologysource.ps1 +++ b/Public/Remove-LMTopologysource.ps1 @@ -31,7 +31,7 @@ Function Remove-LMTopologysource { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMUnmonitoredDevice.ps1 b/Public/Remove-LMUnmonitoredDevice.ps1 index 9b117ab..8177aca 100644 --- a/Public/Remove-LMUnmonitoredDevice.ps1 +++ b/Public/Remove-LMUnmonitoredDevice.ps1 @@ -17,7 +17,7 @@ Function Remove-LMUnmonitoredDevice { $Message = "Id(s): $Ids" Try { - if ($PSCmdlet.ShouldProcess($Message, "Remove Unmonitored Devices")) { + If ($PSCmdlet.ShouldProcess($Message, "Remove Unmonitored Devices")) { [String[]]$Data = $Ids $Data = ($Data | ConvertTo-Json -AsArray) diff --git a/Public/Remove-LMUser.ps1 b/Public/Remove-LMUser.ps1 index 954bb91..37ef3c5 100644 --- a/Public/Remove-LMUser.ps1 +++ b/Public/Remove-LMUser.ps1 @@ -29,7 +29,7 @@ Function Remove-LMUser { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.username)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMWebsite.ps1 b/Public/Remove-LMWebsite.ps1 index e8a1894..5859fcc 100644 --- a/Public/Remove-LMWebsite.ps1 +++ b/Public/Remove-LMWebsite.ps1 @@ -30,7 +30,7 @@ Function Remove-LMWebsite { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Remove-LMWebsiteGroup.ps1 b/Public/Remove-LMWebsiteGroup.ps1 index 7cb5674..12826ce 100644 --- a/Public/Remove-LMWebsiteGroup.ps1 +++ b/Public/Remove-LMWebsiteGroup.ps1 @@ -35,7 +35,7 @@ Function Remove-LMWebsiteGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { diff --git a/Public/Send-LMLogMessage.ps1 b/Public/Send-LMLogMessage.ps1 index ec0dfd3..17f6713 100644 --- a/Public/Send-LMLogMessage.ps1 +++ b/Public/Send-LMLogMessage.ps1 @@ -80,7 +80,7 @@ Function Send-LMLogMessage { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } $Entries += $Data $Entries = ConvertTo-Json -InputObject $Entries } diff --git a/Public/Send-LMPushMetric.ps1 b/Public/Send-LMPushMetric.ps1 index 820ce6e..05bef63 100644 --- a/Public/Send-LMPushMetric.ps1 +++ b/Public/Send-LMPushMetric.ps1 @@ -101,7 +101,7 @@ Function Send-LMPushMetric { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "instances") { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "instances") { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json -Depth 10) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/Set-LMAPIToken.ps1 b/Public/Set-LMAPIToken.ps1 index 044301f..b1010b8 100644 --- a/Public/Set-LMAPIToken.ps1 +++ b/Public/Set-LMAPIToken.ps1 @@ -49,7 +49,7 @@ Function Set-LMAPIToken { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } If ($Status) { $Data.status = $(If ($Status -eq "active") { 2 }Else { 1 }) diff --git a/Public/Set-LMAppliesToFunction.ps1 b/Public/Set-LMAppliesToFunction.ps1 index a852727..1d4a668 100644 --- a/Public/Set-LMAppliesToFunction.ps1 +++ b/Public/Set-LMAppliesToFunction.ps1 @@ -46,7 +46,7 @@ Function Set-LMAppliesToFunction { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMCollector.ps1 b/Public/Set-LMCollector.ps1 index dcff40d..6bc1e1b 100644 --- a/Public/Set-LMCollector.ps1 +++ b/Public/Set-LMCollector.ps1 @@ -57,7 +57,7 @@ Function Set-LMCollector { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.hostname) | Description: $($PSItem.description)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name)" } Else { @@ -82,7 +82,7 @@ Function Set-LMCollector { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMCollectorConfig.ps1 b/Public/Set-LMCollectorConfig.ps1 index e5d9209..c703de4 100644 --- a/Public/Set-LMCollectorConfig.ps1 +++ b/Public/Set-LMCollectorConfig.ps1 @@ -95,7 +95,7 @@ Function Set-LMCollectorConfig { Begin {} Process { Function Process-CollectorConfig { - Param( + Param ( $Config, $ConfLine, $Value @@ -104,7 +104,7 @@ Function Set-LMCollectorConfig { $Value = $Value.toString().toLower() $ConfigArray = $Config.Split([Environment]::NewLine) - [int[]]$Index = [Linq.Enumerable]::Range(0, $ConfigArray.Count).Where({ param($i) $ConfigArray[$i] -match $ConfLine }) + [int[]]$Index = [Linq.Enumerable]::Range(0, $ConfigArray.Count).Where({ Param($i) $ConfigArray[$i] -match $ConfLine }) If (($Index | Measure-Object).Count -eq 1) { Write-LMHost "[INFO]: Updating config parameter $ConfLine to value $Value." $ConfigArray[$Index[0]] = "$ConfLine=$Value" @@ -134,9 +134,9 @@ Function Set-LMCollectorConfig { $SnippetArray = [System.Collections.ArrayList]@() $cmdName = $MyInvocation.InvocationName $paramList = (Get-Command -Name $cmdName).Parameters - foreach ( $key in $paramList.Keys ) { + Foreach ( $key in $paramList.Keys ) { $value = (Get-Variable $key -ErrorAction SilentlyContinue).Value - if ( ($value -or $value -eq 0) -and ($key -ne "Id" -and $key -ne "Name" -and $key -ne "WaitForRestart") ) { + If ( ($value -or $value -eq 0) -and ($key -ne "Id" -and $key -ne "Name" -and $key -ne "WaitForRestart") ) { $SnippetArray.Add(@{$key = $value }) | Out-Null } } @@ -173,7 +173,7 @@ Function Set-LMCollectorConfig { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.hostname) | Description: $($PSItem.description)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name)" } Else { @@ -192,7 +192,7 @@ Function Set-LMCollectorConfig { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMCollectorGroup.ps1 b/Public/Set-LMCollectorGroup.ps1 index 7c399fc..1697b44 100644 --- a/Public/Set-LMCollectorGroup.ps1 +++ b/Public/Set-LMCollectorGroup.ps1 @@ -47,7 +47,7 @@ Function Set-LMCollectorGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | Description: $($PSItem.description)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name)" } Else { @@ -66,7 +66,7 @@ Function Set-LMCollectorGroup { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMConfigsource.ps1 b/Public/Set-LMConfigsource.ps1 index b5198fe..509c352 100644 --- a/Public/Set-LMConfigsource.ps1 +++ b/Public/Set-LMConfigsource.ps1 @@ -44,7 +44,7 @@ Function Set-LMConfigsource { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { @@ -63,7 +63,7 @@ Function Set-LMConfigsource { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMDatasource.ps1 b/Public/Set-LMDatasource.ps1 index c48645c..1066a2b 100644 --- a/Public/Set-LMDatasource.ps1 +++ b/Public/Set-LMDatasource.ps1 @@ -43,7 +43,7 @@ Function Set-LMDatasource { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { @@ -62,7 +62,7 @@ Function Set-LMDatasource { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMDevice.ps1 b/Public/Set-LMDevice.ps1 index b13aa5c..51dcee2 100644 --- a/Public/Set-LMDevice.ps1 +++ b/Public/Set-LMDevice.ps1 @@ -67,7 +67,7 @@ Function Set-LMDevice { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | DisplayName: $($PSItem.displayName)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name" } Else { @@ -94,7 +94,7 @@ Function Set-LMDevice { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMDeviceDatasourceInstance.ps1 b/Public/Set-LMDeviceDatasourceInstance.ps1 index 1a08ad4..34feecc 100644 --- a/Public/Set-LMDeviceDatasourceInstance.ps1 +++ b/Public/Set-LMDeviceDatasourceInstance.ps1 @@ -77,7 +77,7 @@ Function Set-LMDeviceDatasourceInstance { If ($PSItem) { $Message = "deviceDisplayName: $($PSItem.deviceDisplayName) | instanceId: $($PSItem.id) | instanceName: $($PSItem.name)" } - ElseIf ($DeviceName) { + Elseif ($DeviceName) { $Message = "deviceDisplayName: $DeviceName | instanceId: $InstanceId" } Else { @@ -97,7 +97,7 @@ Function Set-LMDeviceDatasourceInstance { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 b/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 index de131a5..6aa5ab0 100644 --- a/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 +++ b/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 @@ -119,7 +119,7 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "alertExpr" -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and $_ -ne "alertExpr" -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) If ($PSCmdlet.ShouldProcess($Message, "Set Device Datasource Instance Alert Setting")) { diff --git a/Public/Set-LMDeviceGroup.ps1 b/Public/Set-LMDeviceGroup.ps1 index 270b95e..5d7ddcb 100644 --- a/Public/Set-LMDeviceGroup.ps1 +++ b/Public/Set-LMDeviceGroup.ps1 @@ -70,7 +70,7 @@ Function Set-LMDeviceGroup { If ($PSItem) { $Message = "Id: $Id | Name: $($PSItem.name) | Path: $($PSItem.fullPath)" } - ElseIf ($Name) { + Elseif ($Name) { $Message = "Id: $Id | Name: $Name)" } Else { @@ -89,7 +89,7 @@ Function Set-LMDeviceGroup { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 b/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 index 5aaf579..d9fb038 100644 --- a/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 +++ b/Public/Set-LMDeviceGroupDatasourceAlertSetting.ps1 @@ -92,7 +92,7 @@ Function Set-LMDeviceGroupDatasourceAlertSetting { } #Remove empty keys so we dont overwrite them - @($dpConfig.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($dpConfig[$_]) -and $_ -ne "alertExpr" -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $dpConfig.Remove($_) } } + @($dpConfig.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($dpConfig[$_]) -and $_ -ne "alertExpr" -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $dpConfig.Remove($_) } } $Data = @{ dpConfig = @($dpConfig) diff --git a/Public/Set-LMNetScan.ps1 b/Public/Set-LMNetScan.ps1 index 434d9c4..e15daef 100644 --- a/Public/Set-LMNetScan.ps1 +++ b/Public/Set-LMNetScan.ps1 @@ -109,7 +109,7 @@ Function Set-LMNetscan { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/Set-LMNetscanGroup.ps1 b/Public/Set-LMNetscanGroup.ps1 index f68cfcb..2257956 100644 --- a/Public/Set-LMNetscanGroup.ps1 +++ b/Public/Set-LMNetscanGroup.ps1 @@ -39,7 +39,7 @@ Function Set-LMNetscanGroup { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMNewUserMessage.ps1 b/Public/Set-LMNewUserMessage.ps1 index ce2a5fe..478bc6a 100644 --- a/Public/Set-LMNewUserMessage.ps1 +++ b/Public/Set-LMNewUserMessage.ps1 @@ -25,7 +25,7 @@ Function Set-LMNewUserMessage { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMOpsNote.ps1 b/Public/Set-LMOpsNote.ps1 index f046244..d29f8c2 100644 --- a/Public/Set-LMOpsNote.ps1 +++ b/Public/Set-LMOpsNote.ps1 @@ -72,7 +72,7 @@ Function Set-LMOpsNote { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } If ($ClearTags) { $Data.tags = @() diff --git a/Public/Set-LMPortalInfo.ps1 b/Public/Set-LMPortalInfo.ps1 index 6757fb7..3a1dcaf 100644 --- a/Public/Set-LMPortalInfo.ps1 +++ b/Public/Set-LMPortalInfo.ps1 @@ -40,7 +40,7 @@ Function Set-LMPortalInfo { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } If ($ClearWhitelist) { $Data.whitelist = "" diff --git a/Public/Set-LMPropertysource.ps1 b/Public/Set-LMPropertysource.ps1 index 42d5dad..a6aaaaf 100644 --- a/Public/Set-LMPropertysource.ps1 +++ b/Public/Set-LMPropertysource.ps1 @@ -53,7 +53,7 @@ Function Set-LMPropertysource { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMReportGroup.ps1 b/Public/Set-LMReportGroup.ps1 index c06ccc6..10337df 100644 --- a/Public/Set-LMReportGroup.ps1 +++ b/Public/Set-LMReportGroup.ps1 @@ -38,7 +38,7 @@ Function Set-LMReportGroup { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMRole.ps1 b/Public/Set-LMRole.ps1 index 4f8144b..87db6aa 100644 --- a/Public/Set-LMRole.ps1 +++ b/Public/Set-LMRole.ps1 @@ -359,7 +359,7 @@ Function Set-LMRole { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) $Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Data $Data diff --git a/Public/Set-LMSDT.ps1 b/Public/Set-LMSDT.ps1 index befb38d..4ffe7b3 100644 --- a/Public/Set-LMSDT.ps1 +++ b/Public/Set-LMSDT.ps1 @@ -73,7 +73,7 @@ Function Set-LMSDT { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMTopologysource.ps1 b/Public/Set-LMTopologysource.ps1 index 41d137a..8b6757c 100644 --- a/Public/Set-LMTopologysource.ps1 +++ b/Public/Set-LMTopologysource.ps1 @@ -52,7 +52,7 @@ Function Set-LMTopologysource { name = "script" } #Remove empty keys so we dont overwrite them - @($collectorAttribute.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($collectorAttribute[$_])) { $collectorAttribute.Remove($_) } } + @($collectorAttribute.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($collectorAttribute[$_])) { $collectorAttribute.Remove($_) } } } Try { @@ -67,7 +67,7 @@ Function Set-LMTopologysource { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMUser.ps1 b/Public/Set-LMUser.ps1 index 28485f7..315892a 100644 --- a/Public/Set-LMUser.ps1 +++ b/Public/Set-LMUser.ps1 @@ -114,7 +114,7 @@ Function Set-LMUser { } break } - ElseIf ($ViewPermission.ContainsKey($View)) { + Elseif ($ViewPermission.ContainsKey($View)) { $ViewPermission[$View] = $true } } @@ -146,7 +146,7 @@ Function Set-LMUser { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMWebsite.ps1 b/Public/Set-LMWebsite.ps1 index 9839c80..ed467f4 100644 --- a/Public/Set-LMWebsite.ps1 +++ b/Public/Set-LMWebsite.ps1 @@ -136,7 +136,7 @@ Function Set-LMWebsite { #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) diff --git a/Public/Set-LMWebsiteGroup.ps1 b/Public/Set-LMWebsiteGroup.ps1 index 5343da8..e4bc0a5 100644 --- a/Public/Set-LMWebsiteGroup.ps1 +++ b/Public/Set-LMWebsiteGroup.ps1 @@ -82,7 +82,7 @@ Function Set-LMWebsiteGroup { } #Remove empty keys so we dont overwrite them - @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + @($Data.keys) | ForEach-Object { If ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } $Data = ($Data | ConvertTo-Json) From 3dfc7bd933036ea7cf0ac9859957b1c06f3075fd Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:05:36 -0400 Subject: [PATCH 3/6] AccessGroup enhancement support Add new cmdlets: - Get/Set/Remove/New -LMAccessGroup support - Get-LMDeviceDatasourceInstanceAlertRecipients --- Documentation/Get-LMAWSAccountId.md | 59 + .../Get-LMConfigsourceUpdateHistory.md | 166 + .../Get-LMDatasourceUpdateHistory.md | 40 +- ...DeviceDatasourceInstanceAlertRecipients.md | 169 + Documentation/Invoke-LMAWSAccountTest.md | 140 + Documentation/Invoke-LMAzureAccountTest.md | 170 + .../Invoke-LMAzureSubscriptionDiscovery.md | 117 + Documentation/Invoke-LMGCPAccountTest.md | 125 + Documentation/New-LMAccessGroup.md | 105 + Documentation/Remove-LMAccessGroup.md | 127 + Documentation/Set-LMAccessGroup.md | 142 + Documentation/Set-LMDevice.md | 35 +- Documentation/Set-LMUserdata.md | 156 + Logic.Monitor.Format.ps1xml | 41 + Public/Get-LMAccessGroup.ps1 | 6 +- ...eviceDatasourceInstanceAlertRecipients.ps1 | 97 + Public/Get-LMDeviceInstanceList.ps1 | 1 - Public/Import-LMRepositoryLogicModules.ps1 | 2 +- Public/New-LMAccessGroup.ps1 | 79 + Public/Remove-LMAccessGroup.ps1 | 98 + Public/Set-LMAccessGroup.ps1 | 114 + en-US/Logic.Monitor-help.xml | 4131 ++++++++++++++--- 22 files changed, 5450 insertions(+), 670 deletions(-) create mode 100644 Documentation/Get-LMAWSAccountId.md create mode 100644 Documentation/Get-LMConfigsourceUpdateHistory.md create mode 100644 Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md create mode 100644 Documentation/Invoke-LMAWSAccountTest.md create mode 100644 Documentation/Invoke-LMAzureAccountTest.md create mode 100644 Documentation/Invoke-LMAzureSubscriptionDiscovery.md create mode 100644 Documentation/Invoke-LMGCPAccountTest.md create mode 100644 Documentation/New-LMAccessGroup.md create mode 100644 Documentation/Remove-LMAccessGroup.md create mode 100644 Documentation/Set-LMAccessGroup.md create mode 100644 Documentation/Set-LMUserdata.md create mode 100644 Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 create mode 100644 Public/New-LMAccessGroup.ps1 create mode 100644 Public/Remove-LMAccessGroup.ps1 create mode 100644 Public/Set-LMAccessGroup.ps1 diff --git a/Documentation/Get-LMAWSAccountId.md b/Documentation/Get-LMAWSAccountId.md new file mode 100644 index 0000000..e0e4dd4 --- /dev/null +++ b/Documentation/Get-LMAWSAccountId.md @@ -0,0 +1,59 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: https://www.logicmonitor.com/support/rest-api-developers-guide/ +schema: 2.0.0 +--- + +# Get-LMAWSAccountId + +## SYNOPSIS +Retrieves the AWS Account ID associated with the LogicMonitor account. + +## SYNTAX + +``` +Get-LMAWSAccountId [-ProgressAction ] [] +``` + +## DESCRIPTION +The Get-LMAWSAccountId function is used to retrieve the AWS Account ID associated with the LogicMonitor account. +It checks if the user is logged in and has valid API credentials. +If the user is logged in, it builds the necessary headers and URI, and then sends a GET request to the LogicMonitor API to retrieve the AWS Account ID. +The function returns the response containing the AWS Account ID. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-LMAWSAccountId +Retrieves the AWS Account ID associated with the LogicMonitor account. +``` + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Documentation/Get-LMConfigsourceUpdateHistory.md b/Documentation/Get-LMConfigsourceUpdateHistory.md new file mode 100644 index 0000000..bccdcea --- /dev/null +++ b/Documentation/Get-LMConfigsourceUpdateHistory.md @@ -0,0 +1,166 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Get-LMConfigsourceUpdateHistory + +## SYNOPSIS +Retrieves the update history for a LogicMonitor configuration source. + +## SYNTAX + +### Id (Default) +``` +Get-LMConfigsourceUpdateHistory -Id [-Filter ] [-BatchSize ] + [-ProgressAction ] [] +``` + +### Name +``` +Get-LMConfigsourceUpdateHistory [-Name ] [-Filter ] [-BatchSize ] + [-ProgressAction ] [] +``` + +### DisplayName +``` +Get-LMConfigsourceUpdateHistory [-DisplayName ] [-Filter ] [-BatchSize ] + [-ProgressAction ] [] +``` + +## DESCRIPTION +The Get-LMConfigsourceUpdateHistory function retrieves the update history for a LogicMonitor configuration source. +It can be used to get information about the updates made to a configuration source, such as the update reasons and the modules that were updated. + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-LMConfigsourceUpdateHistory -Id 1234 +Retrieves the update history for the configuration source with the ID 1234. +``` + +### EXAMPLE 2 +``` +Get-LMConfigsourceUpdateHistory -Name "MyConfigSource" +Retrieves the update history for the configuration source with the name "MyConfigSource". +``` + +### EXAMPLE 3 +``` +Get-LMConfigsourceUpdateHistory -DisplayName "My Config Source" +Retrieves the update history for the configuration source with the display name "My Config Source". +``` + +## PARAMETERS + +### -Id +The ID of the configuration source. +This parameter is mandatory when using the 'Id' parameter set. + +```yaml +Type: Int32 +Parameter Sets: Id +Aliases: + +Required: True +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The name of the configuration source. +This parameter is used to look up the ID of the configuration source. +This parameter is used when using the 'Name' parameter set. + +```yaml +Type: String +Parameter Sets: Name +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DisplayName +The display name of the configuration source. +This parameter is used to look up the ID of the configuration source. +This parameter is used when using the 'DisplayName' parameter set. + +```yaml +Type: String +Parameter Sets: DisplayName +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Filter +A filter object that specifies additional filtering criteria for the update history. +This parameter is optional. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -BatchSize +The number of results to retrieve per request. +The default value is 1000. +This parameter is optional. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 1000 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Documentation/Get-LMDatasourceUpdateHistory.md b/Documentation/Get-LMDatasourceUpdateHistory.md index 2ee06af..76759c5 100644 --- a/Documentation/Get-LMDatasourceUpdateHistory.md +++ b/Documentation/Get-LMDatasourceUpdateHistory.md @@ -44,27 +44,27 @@ PS C:\> {{ Add example code here }} ## PARAMETERS -### -BatchSize -{{ Fill BatchSize Description }} +### -Id +{{ Fill Id Description }} ```yaml Type: Int32 -Parameter Sets: (All) +Parameter Sets: Id Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -DisplayName -{{ Fill DisplayName Description }} +### -Name +{{ Fill Name Description }} ```yaml Type: String -Parameter Sets: DisplayName +Parameter Sets: Name Aliases: Required: False @@ -74,12 +74,12 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Filter -{{ Fill Filter Description }} +### -DisplayName +{{ Fill DisplayName Description }} ```yaml -Type: Object -Parameter Sets: (All) +Type: String +Parameter Sets: DisplayName Aliases: Required: False @@ -89,27 +89,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Id -{{ Fill Id Description }} +### -Filter +{{ Fill Filter Description }} ```yaml -Type: Int32 -Parameter Sets: Id +Type: Object +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Name -{{ Fill Name Description }} +### -BatchSize +{{ Fill BatchSize Description }} ```yaml -Type: String -Parameter Sets: Name +Type: Int32 +Parameter Sets: (All) Aliases: Required: False diff --git a/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md b/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md new file mode 100644 index 0000000..8e5a5b2 --- /dev/null +++ b/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md @@ -0,0 +1,169 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Get-LMDeviceDatasourceInstanceAlertRecipients + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +### Name-dsName +``` +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceName -Name -InstanceName + -DataPointName [-ProgressAction ] [] +``` + +### Id-dsName +``` +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceName -Id -InstanceName + -DataPointName [-ProgressAction ] [] +``` + +### Name-dsId +``` +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceId -Name -InstanceName + -DataPointName [-ProgressAction ] [] +``` + +### Id-dsId +``` +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceId -Id -InstanceName + -DataPointName [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -DataPointName +{{ Fill DataPointName Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasourceId +{{ Fill DatasourceId Description }} + +```yaml +Type: Int32 +Parameter Sets: Name-dsId, Id-dsId +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasourceName +{{ Fill DatasourceName Description }} + +```yaml +Type: String +Parameter Sets: Name-dsName, Id-dsName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Id +{{ Fill Id Description }} + +```yaml +Type: Int32 +Parameter Sets: Id-dsName, Id-dsId +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InstanceName +{{ Fill InstanceName Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +{{ Fill Name Description }} + +```yaml +Type: String +Parameter Sets: Name-dsName, Name-dsId +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS diff --git a/Documentation/Invoke-LMAWSAccountTest.md b/Documentation/Invoke-LMAWSAccountTest.md new file mode 100644 index 0000000..33d4407 --- /dev/null +++ b/Documentation/Invoke-LMAWSAccountTest.md @@ -0,0 +1,140 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Invoke-LMAWSAccountTest + +## SYNOPSIS +Invokes a test for an AWS account in LogicMonitor. + +## SYNTAX + +``` +Invoke-LMAWSAccountTest [-ExternalId] [[-AccountId] ] [-AssumedRoleARN] + [[-CheckedServices] ] [[-GroupId] ] [-ProgressAction ] [] +``` + +## DESCRIPTION +The Invoke-LMAWSAccountTest function is used to invoke a test for an AWS account in LogicMonitor. +It checks if the user is logged in and has valid API credentials. +If the user is logged in, it builds the necessary headers and URI, prepares the data, and sends a POST request to the LogicMonitor API to perform the test. +The function returns the response from the API. + +## EXAMPLES + +### EXAMPLE 1 +``` +Invoke-LMAWSAccountTest -ExternalId "123456" -AccountId "987654" -AccessId "AKI123" -AccessKey "abc123" -AssumedRoleARN "arn:aws:iam::123456789012:role/MyRole" -CheckedServices "EC2,S3,RDS" -GroupId 123 +``` + +This example invokes a test for an AWS account with the specified parameters. + +## PARAMETERS + +### -ExternalId +The external ID of the AWS account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AccountId +The account ID of the AWS account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AssumedRoleARN +The assumed role ARN of the AWS account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -CheckedServices +The list of services to be checked during the test. +Default value is a comma-separated string of service names supported by LogicMonitor. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: DYNAMODB,EBS,EC2,AUTOSCALING,BACKUP,BACKUPPROTECTEDRESOURCE,TRANSFER,ELASTICACHE,ELB,RDS,REDSHIFT,S3,SNS,SQS,EMR,KINESIS,ROUTE53,ROUTE53HOSTEDZONE,CLOUDSEARCH,LAMBDA,ECR,ECS,ELASTICSEARCH,EFS,SWFWORKFLOW,SWFACTIVITY,APPLICATIONELB,CLOUDFRONT,APIGATEWAY,APIGATEWAYV2,SES,VPN,FIREHOSE,KINESISVIDEO,WORKSPACE,NETWORKELB,NATGATEWAY,DIRECTCONNECT,DIRECTCONNECT_VIRTUALINTERFACE,WORKSPACEDIRECTORY,ELASTICBEANSTALK,DMSREPLICATION,MSKCLUSTER,MSKBROKER,FSX,TRANSITGATEWAY,GLUE,APPSTREAM,MQ,ATHENA,DBCLUSTER,DOCDB,STEPFUNCTIONS,OPSWORKS,CODEBUILD,SAGEMAKER,ROUTE53RESOLVER,DMSREPLICATIONTASKS,EVENTBRIDGE,MEDIACONNECT,MEDIAPACKAGELIVE,MEDIASTORE,MEDIAPACKAGEVOD,MEDIATAILOR,MEDIACONVERT,ELASTICTRANSCODER,COGNITO,TRANSITGATEWAYATTACHMENT,QUICKSIGHT_DASHBOARDS,QUICKSIGHT_DATASETS,PRIVATELINK_ENDPOINTS,PRIVATELINK_SERVICES,GLOBAL_NETWORKS +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -GroupId +The device group ID to which the AWS account belongs. +Default value is -1 for no group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: -1 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES +This function requires the user to be logged in before running any commands. +Use the Connect-LMAccount function to log in before invoking this function. + +## RELATED LINKS diff --git a/Documentation/Invoke-LMAzureAccountTest.md b/Documentation/Invoke-LMAzureAccountTest.md new file mode 100644 index 0000000..2a92c43 --- /dev/null +++ b/Documentation/Invoke-LMAzureAccountTest.md @@ -0,0 +1,170 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Invoke-LMAzureAccountTest + +## SYNOPSIS +Invokes a test on an Azure account. + +## SYNTAX + +``` +Invoke-LMAzureAccountTest [-ClientId] [-SecretKey] [[-CheckedServices] ] + [-SubscriptionIds] [[-GroupId] ] [-TenantId] [[-IsChinaAccount] ] + [-ProgressAction ] [] +``` + +## DESCRIPTION +The Invoke-LMAzureAccountTest function is used to invoke a test on an Azure account. +It checks if the user is logged in and has valid API credentials. +If the user is logged in, it builds the necessary headers and URI, and then sends a POST request to the specified endpoint. +The function returns the response from the API. + +## EXAMPLES + +### EXAMPLE 1 +``` +Invoke-LMAzureAccountTest -ClientId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SecretKey "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SubscriptionIds "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +``` + +This example invokes a test on an Azure account using the specified client ID, secret key, and subscription IDs. + +## PARAMETERS + +### -ClientId +The client ID of the Azure account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SecretKey +The secret key of the Azure account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -CheckedServices +The list of services to be checked. +Default value is a list of commonly used Azure services. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: VIRTUALMACHINE,SQLDATABASE,APPSERVICE,EVENTHUB,REDISCACHE,REDISCACHEENTERPRISE,VIRTUALMACHINESCALESET,VIRTUALMACHINESCALESETVM,APPLICATIONGATEWAY,IOTHUB,FUNCTION,SERVICEBUS,MARIADB,MYSQL,MYSQLFLEXIBLE,POSTGRESQL,POSTGRESQLFLEXIBLE,POSTGRESQLCITUS,ANALYSISSERVICE,TABLESTORAGE,BLOBSTORAGE,FILESTORAGE,QUEUESTORAGE,STORAGEACCOUNT,APIMANAGEMENT,COSMOSDB,APPSERVICEPLAN,VIRTUALNETWORKGATEWAY,AUTOMATIONACCOUNT,EXPRESSROUTECIRCUIT,DATALAKEANALYTICS,DATALAKESTORE,APPLICATIONINSIGHTS,FIREWALL,SQLELASTICPOOL,SQLMANAGEDINSTANCE,HDINSIGHT,RECOVERYSERVICES,BACKUPPROTECTEDITEMS,RECOVERYPROTECTEDITEMS,NETWORKINTERFACE,BATCHACCOUNT,LOGICAPPS,DATAFACTORY,PUBLICIP,STREAMANALYTICS,EVENTGRID,LOADBALANCERS,SERVICEFABRICMESH,COGNITIVESEARCH,COGNITIVESERVICES,MLWORKSPACES,FRONTDOORS,KEYVAULT,RELAYNAMESPACES,NOTIFICATIONHUBS,APPSERVICEENVIRONMENT,TRAFFICMANAGER,SIGNALR,VIRTUALDESKTOP,SYNAPSEWORKSPACES,NETAPPPOOLS,DATABRICKS,LOGANALYTICSWORKSPACES,VIRTUALHUBS,VPNGATEWAYS,CDNPROFILE,POWERBIEMBEDDED,CONTAINERREGISTRY,NATGATEWAYS,BOTSERVICES,VIRTUALNETWORKS +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SubscriptionIds +The subscription IDs associated with the Azure account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -GroupId +The group ID. +Default value is -1. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: -1 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TenantId +The tenant ID of the Azure account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IsChinaAccount +Specifies whether the Azure account is a China account. +Default value is $false. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 7 +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Documentation/Invoke-LMAzureSubscriptionDiscovery.md b/Documentation/Invoke-LMAzureSubscriptionDiscovery.md new file mode 100644 index 0000000..a5ba992 --- /dev/null +++ b/Documentation/Invoke-LMAzureSubscriptionDiscovery.md @@ -0,0 +1,117 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Invoke-LMAzureSubscriptionDiscovery + +## SYNOPSIS +Invokes the Azure subscription discovery process to return subscriptions for a specified client Id. + +## SYNTAX + +``` +Invoke-LMAzureSubscriptionDiscovery [-ClientId] [-SecretKey] [-TenantId] + [[-IsChinaAccount] ] [-ProgressAction ] [] +``` + +## DESCRIPTION +The Invoke-LMAzureSubscriptionDiscovery function is used to discover Azure subscriptions by making API requests to the LogicMonitor platform. + +## EXAMPLES + +### EXAMPLE 1 +``` +Invoke-LMAzureSubscriptionDiscovery -ClientId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SecretKey "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +``` + +## PARAMETERS + +### -ClientId +The client ID of the Azure Active Directory application. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SecretKey +The secret key of the Azure Active Directory application. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TenantId +The tenant ID of the Azure Active Directory application. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IsChinaAccount +Specifies whether the Azure account is a China account. +Default value is $false. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Documentation/Invoke-LMGCPAccountTest.md b/Documentation/Invoke-LMGCPAccountTest.md new file mode 100644 index 0000000..796ae5e --- /dev/null +++ b/Documentation/Invoke-LMGCPAccountTest.md @@ -0,0 +1,125 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Invoke-LMGCPAccountTest + +## SYNOPSIS +Invokes a test for a GCP (Google Cloud Platform) account. + +## SYNTAX + +``` +Invoke-LMGCPAccountTest [-ServiceAccountKey] [-ProjectId] [[-CheckedServices] ] + [[-GroupId] ] [-ProgressAction ] [] +``` + +## DESCRIPTION +The Invoke-LMGCPAccountTest function is used to invoke a test for a GCP account. +It checks if the user is logged in and has valid API credentials. +If the user is logged in, it builds the necessary headers and URI, prepares the data, and sends a POST request to the LogicMonitor API to perform the test. +The function returns the response from the API. + +## EXAMPLES + +### EXAMPLE 1 +``` +Invoke-LMGCPAccountTest -ServiceAccountKey "service-account-key" -ProjectId "project-id" +``` + +This example invokes a test for a GCP account using the specified service account key and project ID. + +## PARAMETERS + +### -ServiceAccountKey +The service account key for the GCP account. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProjectId +The ID of the GCP project. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -CheckedServices +(Optional) A comma-separated list of GCP services to be checked. +The default value is a list of all LM supported GCP services. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: CLOUDRUN,CLOUDDNS,REGIONALHTTPSLOADBALANCER,COMPUTEENGINEAUTOSCALER,COMPUTEENGINE,CLOUDIOT,CLOUDROUTER,CLOUDTASKS,VPNGATEWAY,CLOUDREDIS,CLOUDCOMPOSER,INTERCONNECTATTACHMENT,CLOUDFUNCTION,CLOUDBIGTABLE,CLOUDFILESTORE,CLOUDPUBSUB,CLOUDTRACE,CLOUDSTORAGE,CLOUDDATAPROC,CLOUDINTERCONNECT,CLOUDAIPLATFORM,CLOUDSQL,MANAGEDSERVICEFORMICROSOFTAD,CLOUDFIRESTORE,CLOUDDATAFLOW,CLOUDTPU,CLOUDDLP,APPENGINE,HTTPSLOADBALANCER,CLOUDSPANNER +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -GroupId +(Optional) The ID of the group to which the GCP account belongs. +The default value is -1, indicating no group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: -1 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES +This function requires the user to be logged in before running any commands. +Use the Connect-LMAccount function to log in before invoking this function. + +## RELATED LINKS diff --git a/Documentation/New-LMAccessGroup.md b/Documentation/New-LMAccessGroup.md new file mode 100644 index 0000000..c14941f --- /dev/null +++ b/Documentation/New-LMAccessGroup.md @@ -0,0 +1,105 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# New-LMAccessGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +New-LMAccessGroup [-Name] [[-Description] ] [[-Tenant] ] + [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Description +{{ Fill Description Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +{{ Fill Name Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tenant +{{ Fill Tenant Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS diff --git a/Documentation/Remove-LMAccessGroup.md b/Documentation/Remove-LMAccessGroup.md new file mode 100644 index 0000000..34f04d3 --- /dev/null +++ b/Documentation/Remove-LMAccessGroup.md @@ -0,0 +1,127 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Remove-LMAccessGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +### Id (Default) +``` +Remove-LMAccessGroup -Id [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +### Name +``` +Remove-LMAccessGroup -Name [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Id +{{ Fill Id Description }} + +```yaml +Type: Int32 +Parameter Sets: Id +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +{{ Fill Name Description }} + +```yaml +Type: String +Parameter Sets: Name +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Int32 +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS diff --git a/Documentation/Set-LMAccessGroup.md b/Documentation/Set-LMAccessGroup.md new file mode 100644 index 0000000..a41bed9 --- /dev/null +++ b/Documentation/Set-LMAccessGroup.md @@ -0,0 +1,142 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Set-LMAccessGroup + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +### Id +``` +Set-LMAccessGroup [-Id ] [-NewName ] [-Description ] [-Tenant ] + [-ProgressAction ] [] +``` + +### Name +``` +Set-LMAccessGroup [-Name ] [-NewName ] [-Description ] [-Tenant ] + [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Description +{{ Fill Description Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Id +{{ Fill Id Description }} + +```yaml +Type: Int32 +Parameter Sets: Id +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +{{ Fill Name Description }} + +```yaml +Type: String +Parameter Sets: Name +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NewName +{{ Fill NewName Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tenant +{{ Fill Tenant Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Int32 +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS diff --git a/Documentation/Set-LMDevice.md b/Documentation/Set-LMDevice.md index 7d0a80c..45427e4 100644 --- a/Documentation/Set-LMDevice.md +++ b/Documentation/Set-LMDevice.md @@ -15,21 +15,21 @@ schema: 2.0.0 ### Id ``` Set-LMDevice -Id [-NewName ] [-DisplayName ] [-Description ] - [-PreferredCollectorId ] [-PreferredCollectorGroupId ] [-Properties ] - [-HostGroupIds ] [-PropertiesMethod ] [-Link ] [-DisableAlerting ] - [-EnableNetFlow ] [-NetflowCollectorGroupId ] [-NetflowCollectorId ] - [-LogCollectorGroupId ] [-LogCollectorId ] [-ProgressAction ] [-WhatIf] - [-Confirm] [] + [-PreferredCollectorId ] [-PreferredCollectorGroupId ] [-AutoBalancedCollectorGroupId ] + [-Properties ] [-HostGroupIds ] [-PropertiesMethod ] [-Link ] + [-DisableAlerting ] [-EnableNetFlow ] [-NetflowCollectorGroupId ] + [-NetflowCollectorId ] [-LogCollectorGroupId ] [-LogCollectorId ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ### Name ``` Set-LMDevice -Name [-NewName ] [-DisplayName ] [-Description ] - [-PreferredCollectorId ] [-PreferredCollectorGroupId ] [-Properties ] - [-HostGroupIds ] [-PropertiesMethod ] [-Link ] [-DisableAlerting ] - [-EnableNetFlow ] [-NetflowCollectorGroupId ] [-NetflowCollectorId ] - [-LogCollectorGroupId ] [-LogCollectorId ] [-ProgressAction ] [-WhatIf] - [-Confirm] [] + [-PreferredCollectorId ] [-PreferredCollectorGroupId ] [-AutoBalancedCollectorGroupId ] + [-Properties ] [-HostGroupIds ] [-PropertiesMethod ] [-Link ] + [-DisableAlerting ] [-EnableNetFlow ] [-NetflowCollectorGroupId ] + [-NetflowCollectorId ] [-LogCollectorGroupId ] [-LogCollectorId ] + [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -46,6 +46,21 @@ PS C:\> {{ Add example code here }} ## PARAMETERS +### -AutoBalancedCollectorGroupId +{{ Fill AutoBalancedCollectorGroupId Description }} + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Confirm Prompts you for confirmation before running the cmdlet. diff --git a/Documentation/Set-LMUserdata.md b/Documentation/Set-LMUserdata.md new file mode 100644 index 0000000..e5d5461 --- /dev/null +++ b/Documentation/Set-LMUserdata.md @@ -0,0 +1,156 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Set-LMUserdata + +## SYNOPSIS +Sets userdata for a LogicMonitor user. +Currently only setting the default dashboard is supported. + +## SYNTAX + +### Id (Default) +``` +Set-LMUserdata -Id -DashboardId [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +### Name +``` +Set-LMUserdata -Name -DashboardId [-ProgressAction ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +The Set-LMUserdata function is used to set the user data for a LogicMonitor user. +It allows you to specify the user by either their Id or Name, and the dashboard Id for which the user data should be set. + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-LMUserdata -Id "12345" -DashboardId "67890" +Sets the user data for the user with Id "12345" for the dashboard with Id "67890". +``` + +### EXAMPLE 2 +``` +Set-LMUserdata -Name "JohnDoe" -DashboardId "67890" +Sets the user data for the user with Name "JohnDoe" for the dashboard with Id "67890". +``` + +## PARAMETERS + +### -Id +Specifies the Id of the user. +This parameter is mandatory when using the 'Id' parameter set. + +```yaml +Type: String +Parameter Sets: Id +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +Specifies the Name of the user. +This parameter is mandatory when using the 'Name' parameter set. + +```yaml +Type: String +Parameter Sets: Name +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DashboardId +Specifies the Id of the dashboard for which the user data should be set. +This parameter is mandatory. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None. +## OUTPUTS + +### System.Object +### Returns the response from the LogicMonitor API. +## NOTES +This function requires a valid API authentication. +Make sure you are logged in before running any commands using Connect-LMAccount. + +## RELATED LINKS diff --git a/Logic.Monitor.Format.ps1xml b/Logic.Monitor.Format.ps1xml index 3d772e3..8d49226 100644 --- a/Logic.Monitor.Format.ps1xml +++ b/Logic.Monitor.Format.ps1xml @@ -54,6 +54,47 @@ + + + LogicMonitorAccessGroup + + LogicMonitor.AccessGroup + + + + + + + + + + + + + + + + + + + + + id + + + name + + + tenantid + + + description + + + + + + LogicMonitorTopologyMap diff --git a/Public/Get-LMAccessGroup.ps1 b/Public/Get-LMAccessGroup.ps1 index 5c3b08f..d7c18f4 100644 --- a/Public/Get-LMAccessGroup.ps1 +++ b/Public/Get-LMAccessGroup.ps1 @@ -26,7 +26,7 @@ Get-LMAccessGroup -Name "MyAccessGroup" Retrieves the access group with the specified name. .EXAMPLE -Get-LMAccessGroup -Filter @{ Property = "Value" } +Get-LMAccessGroup -Filter "tenantId -eq 'Value'" Retrieves access groups based on the specified filter criteria. .NOTES @@ -88,7 +88,7 @@ Function Get-LMAccessGroup { #Stop looping if single device, no need to continue If ($PSCmdlet.ParameterSetName -eq "Id") { $Done = $true - Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.Role" ) + Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.AccessGroup" ) } #Check result size and if needed loop again Else { @@ -107,7 +107,7 @@ Function Get-LMAccessGroup { } } } - Return (Add-ObjectTypeInfo -InputObject $Results -TypeName "LogicMonitor.Role" ) + Return (Add-ObjectTypeInfo -InputObject $Results -TypeName "LogicMonitor.AccessGroup" ) } Else { Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." diff --git a/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 b/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 new file mode 100644 index 0000000..8e2ffe0 --- /dev/null +++ b/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 @@ -0,0 +1,97 @@ +Function Get-LMDeviceDatasourceInstanceAlertRecipients { + + [CmdletBinding()] + Param ( + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] + [String]$DatasourceName, + + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Int]$DatasourceId, + + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Int]$Id, + + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [String]$Name, + + [Parameter(Mandatory)] + [String]$InstanceName, + + [Parameter(Mandatory)] + [String]$DataPointName + ) + #Check if we are logged in and have valid api creds + If ($Script:LMAuth.Valid) { + + #Lookup Device Id + If ($Name) { + $LookupResult = (Get-LMDevice -Name $Name).Id + If (Test-LookupResult -Result $LookupResult -LookupString $Name) { + return + } + $Id = $LookupResult + } + + #Lookup Hdsid + If ($DatasourceName -or $DatasourceId) { + $LookupResult = (Get-LMDeviceDataSourceList -Id $Id | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id + If (Test-LookupResult -Result $LookupResult -LookupString $DatasourceName) { + return + } + $HdsId = $LookupResult + } + #Lookup HdsiId + If ($DatasourceName) { + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id + If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { + return + } + $HdsiId = $LookupResult + } + Else{ + $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceId $DatasourceId -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id + If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { + return + } + $HdsiId = $LookupResult + } + + #Get datapoint id + $LookupResult = (Get-LMDeviceDatasourceInstanceAlertSetting -DatasourceId $DatasourceId -Id $Id -InstanceName $InstanceName | Where-Object { $_.dataPointName -like "*$DataPointName"}).Id + If (Test-LookupResult -Result $LookupResult -LookupString $DataPointName) { + return + } + $DsidpId = $LookupResult + + #Build header and uri + $ResourcePath = "/device/devices/$Id/devicedatasources/$HdsId/instances/$HdsiId/alertsettings/$DsidpId/recipients" + + #Initalize vars + $Results = @() + + Try { + $Headers = New-LMHeader -Auth $Script:LMAuth -Method "GET" -ResourcePath $ResourcePath + $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation + + #Issue request + $Response = Invoke-RestMethod -Uri $Uri -Method "GET" -Headers $Headers[0] -WebSession $Headers[1] + + } + Catch [Exception] { + $Proceed = Resolve-LMException -LMException $PSItem + If (!$Proceed) { + Return + } + } + Return $Response + } + Else { + Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." + } +} diff --git a/Public/Get-LMDeviceInstanceList.ps1 b/Public/Get-LMDeviceInstanceList.ps1 index 0ee646e..bdb7893 100644 --- a/Public/Get-LMDeviceInstanceList.ps1 +++ b/Public/Get-LMDeviceInstanceList.ps1 @@ -63,7 +63,6 @@ Function Get-LMDeviceInstanceList { return $Response.Total } - #Stop looping if single device, no need to continue If (![bool]$Response.psobject.Properties["total"]) { $Done = $true diff --git a/Public/Import-LMRepositoryLogicModules.ps1 b/Public/Import-LMRepositoryLogicModules.ps1 index 0c3cd31..ed3d6e8 100644 --- a/Public/Import-LMRepositoryLogicModules.ps1 +++ b/Public/Import-LMRepositoryLogicModules.ps1 @@ -58,7 +58,7 @@ Function Import-LMRepositoryLogicModules { #Issue request $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data - + Return "Modules imported successfully: $LogicModuleNames" } Catch [Exception] { diff --git a/Public/New-LMAccessGroup.ps1 b/Public/New-LMAccessGroup.ps1 new file mode 100644 index 0000000..52e2100 --- /dev/null +++ b/Public/New-LMAccessGroup.ps1 @@ -0,0 +1,79 @@ +<# +.SYNOPSIS +Creates a new LogicMonitor access group. + +.DESCRIPTION +The New-LMAccessGroup function is used to create a new access group in LogicMonitor. An access group is a collection of users with similar permissions and access rights for managing modules in the LM exchange and my module toolbox. + +.PARAMETER Name +The name of the access group. This parameter is mandatory. + +.PARAMETER Description +The description of the access group. + +.PARAMETER Tenant +The ID of the tenant to which the access group belongs. + +.EXAMPLE +New-LMAccessGroup -Name "Group1" -Description "Access group for administrators" -Tenant "12345" + +This example creates a new access group named "Group1" with the description "Access group for administrators" and assigns it to the tenant with ID "12345". + +.NOTES +For this function to work, you need to be logged in and have valid API credentials. Use the Connect-LMAccount function to log in before running any commands. +#> +Function New-LMAccessGroup { + + [CmdletBinding()] + Param ( + + [Parameter(Mandatory)] + [String]$Name, + + [String]$Description, + + [String]$Tenant + + ) + #Check if we are logged in and have valid api creds + Begin {} + Process { + If ($Script:LMAuth.Valid) { + + #Build header and uri + $ResourcePath = "/setting/accessgroup/add" + + Try { + $Data = @{ + description = $Description + name = $Name + tenantId = $Tenant + } + + #Remove empty keys so we dont overwrite them + @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_])) { $Data.Remove($_) } } + + $Data = ($Data | ConvertTo-Json) + $Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Data $Data + $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data + + #Issue request + $Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data + + Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.AccessGroup" ) + } + Catch [Exception] { + $Proceed = Resolve-LMException -LMException $PSItem + If (!$Proceed) { + Return + } + } + } + Else { + Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." + } + } + End {} +} diff --git a/Public/Remove-LMAccessGroup.ps1 b/Public/Remove-LMAccessGroup.ps1 new file mode 100644 index 0000000..c6de606 --- /dev/null +++ b/Public/Remove-LMAccessGroup.ps1 @@ -0,0 +1,98 @@ +<# +.SYNOPSIS +Removes a LogicMonitor access group. + +.DESCRIPTION +The Remove-LMAccessGroup function removes a LogicMonitor access group based on the specified ID or name. + +.PARAMETER Id +The ID of the access group to remove. This parameter is mandatory when using the 'Id' parameter set. + +.PARAMETER Name +The name of the access group to remove. This parameter is mandatory when using the 'Name' parameter set. + +.EXAMPLE +Remove-LMAccessGroup -Id 123 +Removes the access group with the ID 123. + +.EXAMPLE +Remove-LMAccessGroup -Name "MyAccessGroup" +Removes the access group with the name "MyAccessGroup". + +.INPUTS +None. + +.OUTPUTS +System.Management.Automation.PSCustomObject + +.NOTES +This function requires a valid LogicMonitor API authentication. Make sure to log in using Connect-LMAccount before running this command. +#> +Function Remove-LMAccessGroup { + + [CmdletBinding(DefaultParameterSetName = 'Id',SupportsShouldProcess,ConfirmImpact='High')] + Param ( + [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] + [Int]$Id, + + [Parameter(Mandatory, ParameterSetName = 'Name')] + [String]$Name + ) + Begin {} + Process { + #Check if we are logged in and have valid api creds + If ($Script:LMAuth.Valid) { + + #Lookup Id if supplying username + If ($Name) { + $LookupResult = (Get-LMAccessGroup -Name $Name).Id + If (Test-LookupResult -Result $LookupResult -LookupString $Name) { + return + } + $Id = $LookupResult + } + + If($PSItem){ + $Message = "Id: $Id | Name: $($PSItem.name)" + } + ElseIf($Name){ + $Message = "Id: $Id | Name: $Name" + } + Else{ + $Message = "Id: $Id" + } + + #Build header and uri + $ResourcePath = "/setting/accessgroup/$Id" + + Try { + If ($PSCmdlet.ShouldProcess($Message, "Remove AccessGroup")) { + $Headers = New-LMHeader -Auth $Script:LMAuth -Method "DELETE" -ResourcePath $ResourcePath + $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation + + #Issue request + $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] + + $Result = [PSCustomObject]@{ + Id = $Id + Message = "Successfully removed ($Message)" + } + + Return $Result + } + } + Catch [Exception] { + $Proceed = Resolve-LMException -LMException $PSItem + If (!$Proceed) { + Return + } + } + } + Else { + Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." + } + } + End {} +} diff --git a/Public/Set-LMAccessGroup.ps1 b/Public/Set-LMAccessGroup.ps1 new file mode 100644 index 0000000..277748c --- /dev/null +++ b/Public/Set-LMAccessGroup.ps1 @@ -0,0 +1,114 @@ +<# +.SYNOPSIS +Sets the properties of a LogicMonitor access group. + +.DESCRIPTION +The Set-LMAccessGroup function is used to set the properties of a LogicMonitor access group. It allows you to specify the access group either by its ID or by its name. You can set the new name, description, and tenant ID for the access group. + +.PARAMETER Id +Specifies the ID of the access group. This parameter is used when you want to set the properties of the access group by its ID. + +.PARAMETER Name +Specifies the name of the access group. This parameter is used when you want to set the properties of the access group by its name. + +.PARAMETER NewName +Specifies the new name for the access group. + +.PARAMETER Description +Specifies the new description for the access group. + +.PARAMETER Tenant +Specifies the tenant ID for the access group. + +.EXAMPLE +Set-LMAccessGroup -Id 123 -NewName "New Access Group" -Description "This is a new access group" -Tenant "abc123" +Sets the properties of the access group with ID 123. The new name is set to "New Access Group", the description is set to "This is a new access group", and the tenant ID is set to "abc123". + +.EXAMPLE +Set-LMAccessGroup -Name "Old Access Group" -NewName "New Access Group" -Description "This is a new access group" -Tenant "abc123" +Sets the properties of the access group with name "Old Access Group". The new name is set to "New Access Group", the description is set to "This is a new access group", and the tenant ID is set to "abc123". + +.NOTES +This function requires you to be logged in and have valid API credentials. Use the Connect-LMAccount function to log in before running this command. +#> +Function Set-LMAccessGroup { + + [CmdletBinding()] + Param ( + + [Parameter(ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] + [Int]$Id, + + [Parameter(ParameterSetName = 'Name')] + [String]$Name, + + [String]$NewName, + + [String]$Description, + + [String]$Tenant + + ) + #Check if we are logged in and have valid api creds + Begin {} + Process { + If ($Script:LMAuth.Valid) { + #Lookup Group Id + If ($Name) { + $LookupResult = (Get-LMAccessGroup -Name $Name).Id + If (Test-LookupResult -Result $LookupResult -LookupString $Name) { + return + } + $Id = $LookupResult + } + + If($PSItem){ + $Message = "Id: $Id | Name: $($PSItem.name) | Description: $($PSItem.description)" + } + ElseIf($Name){ + $Message = "Id: $Id | Name: $Name)" + } + Else{ + $Message = "Id: $Id" + } + + #Build header and uri + $ResourcePath = "/setting/accessgroup/$Id" + + Try { + $Data = @{ + description = $Description + name = $NewName + tenantId = $Tenant + } + + #Remove empty keys so we dont overwrite them + @($Data.keys) | ForEach-Object { if ([string]::IsNullOrEmpty($Data[$_]) -and ($_ -notin @($MyInvocation.BoundParameters.Keys))) { $Data.Remove($_) } } + + $Data = ($Data | ConvertTo-Json) + + If ($PSCmdlet.ShouldProcess($Message, "Set AccessGroup")) { + $Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Data $Data + $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data + + #Issue request + $Response = Invoke-RestMethod -Uri $Uri -Method "PATCH" -Headers $Headers[0] -WebSession $Headers[1] -Body $Data + + Return (Add-ObjectTypeInfo -InputObject $Response -TypeName "LogicMonitor.AccessGroup" ) + } + } + Catch [Exception] { + $Proceed = Resolve-LMException -LMException $PSItem + If (!$Proceed) { + Return + } + } + } + Else { + Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." + } + } + End {} +} diff --git a/en-US/Logic.Monitor-help.xml b/en-US/Logic.Monitor-help.xml index 37857cf..7f730c1 100644 --- a/en-US/Logic.Monitor-help.xml +++ b/en-US/Logic.Monitor-help.xml @@ -2445,6 +2445,234 @@ Creates a copy of the device specified by the $deviceObject variable with the na + + + Get-LMAccessGroup + Get + LMAccessGroup + + Retrieves LogicMonitor access groups based on specified parameters. + + + + The Get-LMAccessGroup function retrieves LogicMonitor access groups based on the specified parameters. It supports retrieving access groups by ID, name, or using a filter. The function uses the LogicMonitor REST API to make the requests. + + + + Get-LMAccessGroup + + Id + + Specifies the ID of the access group to retrieve. This parameter is mutually exclusive with the Name and Filter parameters. + + Int32 + + Int32 + + + 0 + + + BatchSize + + Specifies the number of access groups to retrieve per request. The default value is 1000. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMAccessGroup + + Name + + Specifies the name of the access group to retrieve. This parameter is mutually exclusive with the Id and Filter parameters. + + String + + String + + + None + + + BatchSize + + Specifies the number of access groups to retrieve per request. The default value is 1000. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMAccessGroup + + Filter + + Specifies a filter object to retrieve access groups based on custom filter criteria. This parameter is mutually exclusive with the Id and Name parameters. + + Object + + Object + + + None + + + BatchSize + + Specifies the number of access groups to retrieve per request. The default value is 1000. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Id + + Specifies the ID of the access group to retrieve. This parameter is mutually exclusive with the Name and Filter parameters. + + Int32 + + Int32 + + + 0 + + + Name + + Specifies the name of the access group to retrieve. This parameter is mutually exclusive with the Id and Filter parameters. + + String + + String + + + None + + + Filter + + Specifies a filter object to retrieve access groups based on custom filter criteria. This parameter is mutually exclusive with the Id and Name parameters. + + Object + + Object + + + None + + + BatchSize + + Specifies the number of access groups to retrieve per request. The default value is 1000. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + This function requires a valid LogicMonitor API authentication. Use Connect-LMAccount to authenticate before running this function. + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-LMAccessGroup -Id 123 +Retrieves the access group with the specified ID. + + + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-LMAccessGroup -Name "MyAccessGroup" +Retrieves the access group with the specified name. + + + + + + -------------------------- EXAMPLE 3 -------------------------- + Get-LMAccessGroup -Filter @{ Property = "Value" } +Retrieves access groups based on the specified filter criteria. + + + + + + + Get-LMAccountStatus @@ -4071,6 +4299,73 @@ Retrieves audit logs that contain the search string "login" and occurred within + + + Get-LMAWSAccountId + Get + LMAWSAccountId + + Retrieves the AWS Account ID associated with the LogicMonitor account. + + + + The Get-LMAWSAccountId function is used to retrieve the AWS Account ID associated with the LogicMonitor account. It checks if the user is logged in and has valid API credentials. If the user is logged in, it builds the necessary headers and URI, and then sends a GET request to the LogicMonitor API to retrieve the AWS Account ID. The function returns the response containing the AWS Account ID. + + + + Get-LMAWSAccountId + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-LMAWSAccountId +Retrieves the AWS Account ID associated with the LogicMonitor account. + + + + + + + + Online Version: + https://www.logicmonitor.com/support/rest-api-developers-guide/ + + + Get-LMCachedAccount @@ -5563,6 +5858,282 @@ Retrieves configuration sources based on the specified filter criteria. + + + Get-LMConfigsourceUpdateHistory + Get + LMConfigsourceUpdateHistory + + Retrieves the update history for a LogicMonitor configuration source. + + + + The Get-LMConfigsourceUpdateHistory function retrieves the update history for a LogicMonitor configuration source. It can be used to get information about the updates made to a configuration source, such as the update reasons and the modules that were updated. + + + + Get-LMConfigsourceUpdateHistory + + Id + + The ID of the configuration source. This parameter is mandatory when using the 'Id' parameter set. + + Int32 + + Int32 + + + 0 + + + Filter + + A filter object that specifies additional filtering criteria for the update history. This parameter is optional. + + Object + + Object + + + None + + + BatchSize + + The number of results to retrieve per request. The default value is 1000. This parameter is optional. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMConfigsourceUpdateHistory + + Name + + The name of the configuration source. This parameter is used to look up the ID of the configuration source. This parameter is used when using the 'Name' parameter set. + + String + + String + + + None + + + Filter + + A filter object that specifies additional filtering criteria for the update history. This parameter is optional. + + Object + + Object + + + None + + + BatchSize + + The number of results to retrieve per request. The default value is 1000. This parameter is optional. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMConfigsourceUpdateHistory + + DisplayName + + The display name of the configuration source. This parameter is used to look up the ID of the configuration source. This parameter is used when using the 'DisplayName' parameter set. + + String + + String + + + None + + + Filter + + A filter object that specifies additional filtering criteria for the update history. This parameter is optional. + + Object + + Object + + + None + + + BatchSize + + The number of results to retrieve per request. The default value is 1000. This parameter is optional. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Id + + The ID of the configuration source. This parameter is mandatory when using the 'Id' parameter set. + + Int32 + + Int32 + + + 0 + + + Name + + The name of the configuration source. This parameter is used to look up the ID of the configuration source. This parameter is used when using the 'Name' parameter set. + + String + + String + + + None + + + DisplayName + + The display name of the configuration source. This parameter is used to look up the ID of the configuration source. This parameter is used when using the 'DisplayName' parameter set. + + String + + String + + + None + + + Filter + + A filter object that specifies additional filtering criteria for the update history. This parameter is optional. + + Object + + Object + + + None + + + BatchSize + + The number of results to retrieve per request. The default value is 1000. This parameter is optional. + + Int32 + + Int32 + + + 1000 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-LMConfigsourceUpdateHistory -Id 1234 +Retrieves the update history for the configuration source with the ID 1234. + + + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-LMConfigsourceUpdateHistory -Name "MyConfigSource" +Retrieves the update history for the configuration source with the name "MyConfigSource". + + + + + + -------------------------- EXAMPLE 3 -------------------------- + Get-LMConfigsourceUpdateHistory -DisplayName "My Config Source" +Retrieves the update history for the configuration source with the display name "My Config Source". + + + + + + + Get-LMDashboard @@ -8471,10 +9042,10 @@ Retrieves the dashboards that match the specified custom filter. Get-LMDatasourceUpdateHistory - - BatchSize + + Id - {{ Fill BatchSize Description }} + {{ Fill Id Description }} Int32 @@ -8484,25 +9055,25 @@ Retrieves the dashboards that match the specified custom filter. None - DisplayName + Filter - {{ Fill DisplayName Description }} + {{ Fill Filter Description }} - String + Object - String + Object None - Filter + BatchSize - {{ Fill Filter Description }} + {{ Fill BatchSize Description }} - Object + Int32 - Object + Int32 None @@ -8523,13 +9094,13 @@ Retrieves the dashboards that match the specified custom filter. Get-LMDatasourceUpdateHistory - BatchSize + Name - {{ Fill BatchSize Description }} + {{ Fill Name Description }} - Int32 + String - Int32 + String None @@ -8546,10 +9117,10 @@ Retrieves the dashboards that match the specified custom filter. None - - Id + + BatchSize - {{ Fill Id Description }} + {{ Fill BatchSize Description }} Int32 @@ -8574,13 +9145,13 @@ Retrieves the dashboards that match the specified custom filter. Get-LMDatasourceUpdateHistory - BatchSize + DisplayName - {{ Fill BatchSize Description }} + {{ Fill DisplayName Description }} - Int32 + String - Int32 + String None @@ -8598,13 +9169,13 @@ Retrieves the dashboards that match the specified custom filter. None - Name + BatchSize - {{ Fill Name Description }} + {{ Fill BatchSize Description }} - String + Int32 - String + Int32 None @@ -8624,10 +9195,10 @@ Retrieves the dashboards that match the specified custom filter. - - BatchSize + + Id - {{ Fill BatchSize Description }} + {{ Fill Id Description }} Int32 @@ -8637,9 +9208,9 @@ Retrieves the dashboards that match the specified custom filter. None - DisplayName + Name - {{ Fill DisplayName Description }} + {{ Fill Name Description }} String @@ -8649,37 +9220,37 @@ Retrieves the dashboards that match the specified custom filter. None - Filter + DisplayName - {{ Fill Filter Description }} + {{ Fill DisplayName Description }} - Object + String - Object + String None - - Id + + Filter - {{ Fill Id Description }} + {{ Fill Filter Description }} - Int32 + Object - Int32 + Object None - Name + BatchSize - {{ Fill Name Description }} + {{ Fill BatchSize Description }} - String + Int32 - String + Int32 None @@ -11205,9 +11776,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceAlertSetting + Get-LMDeviceDatasourceInstanceAlertRecipients Get - LMDeviceDatasourceInstanceAlertSetting + LMDeviceDatasourceInstanceAlertRecipients {{ Fill in the Synopsis }} @@ -11217,15 +11788,15 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceAlertSetting - - BatchSize + Get-LMDeviceDatasourceInstanceAlertRecipients + + DataPointName - {{ Fill BatchSize Description }} + {{ Fill DataPointName Description }} - Int32 + String - Int32 + String None @@ -11242,18 +11813,6 @@ Retrieves the dashboards that match the specified custom filter. None - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - InstanceName @@ -11292,15 +11851,15 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceAlertSetting - - BatchSize + Get-LMDeviceDatasourceInstanceAlertRecipients + + DataPointName - {{ Fill BatchSize Description }} + {{ Fill DataPointName Description }} - Int32 + String - Int32 + String None @@ -11317,18 +11876,6 @@ Retrieves the dashboards that match the specified custom filter. None - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - Id @@ -11367,15 +11914,15 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceAlertSetting - - BatchSize + Get-LMDeviceDatasourceInstanceAlertRecipients + + DataPointName - {{ Fill BatchSize Description }} + {{ Fill DataPointName Description }} - Int32 + String - Int32 + String None @@ -11392,18 +11939,6 @@ Retrieves the dashboards that match the specified custom filter. None - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - InstanceName @@ -11442,15 +11977,15 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceAlertSetting - - BatchSize + Get-LMDeviceDatasourceInstanceAlertRecipients + + DataPointName - {{ Fill BatchSize Description }} + {{ Fill DataPointName Description }} - Int32 + String - Int32 + String None @@ -11467,18 +12002,6 @@ Retrieves the dashboards that match the specified custom filter. None - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - Id @@ -11518,14 +12041,14 @@ Retrieves the dashboards that match the specified custom filter. - - BatchSize + + DataPointName - {{ Fill BatchSize Description }} + {{ Fill DataPointName Description }} - Int32 + String - Int32 + String None @@ -11554,18 +12077,6 @@ Retrieves the dashboards that match the specified custom filter. None - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - Id @@ -11653,9 +12164,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceGroup + Get-LMDeviceDatasourceInstanceAlertSetting Get - LMDeviceDatasourceInstanceGroup + LMDeviceDatasourceInstanceAlertSetting {{ Fill in the Synopsis }} @@ -11665,70 +12176,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceDatasourceInstanceGroup - - BatchSize - - {{ Fill BatchSize Description }} - - Int32 - - Int32 - - - None - - - DatasourceId - - {{ Fill DatasourceId Description }} - - Int32 - - Int32 - - - None - - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - - - Name - - {{ Fill Name Description }} - - String - - String - - - None - - - ProgressAction - - {{ Fill ProgressAction Description }} - - ActionPreference - - ActionPreference - - - None - - - - Get-LMDeviceDatasourceInstanceGroup + Get-LMDeviceDatasourceInstanceAlertSetting BatchSize @@ -11766,48 +12214,9 @@ Retrieves the dashboards that match the specified custom filter. None - Id - - {{ Fill Id Description }} - - Int32 - - Int32 - - - None - - - ProgressAction - - {{ Fill ProgressAction Description }} - - ActionPreference - - ActionPreference - - - None - - - - Get-LMDeviceDatasourceInstanceGroup - - BatchSize - - {{ Fill BatchSize Description }} - - Int32 - - Int32 - - - None - - - DatasourceName + InstanceName - {{ Fill DatasourceName Description }} + {{ Fill InstanceName Description }} String @@ -11816,18 +12225,568 @@ Retrieves the dashboards that match the specified custom filter. None - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMDeviceDatasourceInstanceAlertSetting + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceId + + {{ Fill DatasourceId Description }} + + Int32 + + Int32 + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + InstanceName + + {{ Fill InstanceName Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMDeviceDatasourceInstanceAlertSetting + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceName + + {{ Fill DatasourceName Description }} + + String + + String + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + InstanceName + + {{ Fill InstanceName Description }} + + String + + String + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMDeviceDatasourceInstanceAlertSetting + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceName + + {{ Fill DatasourceName Description }} + + String + + String + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + InstanceName + + {{ Fill InstanceName Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceId + + {{ Fill DatasourceId Description }} + + Int32 + + Int32 + + + None + + + DatasourceName + + {{ Fill DatasourceName Description }} + + String + + String + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + InstanceName + + {{ Fill InstanceName Description }} + + String + + String + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-LMDeviceDatasourceInstanceGroup + Get + LMDeviceDatasourceInstanceGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-LMDeviceDatasourceInstanceGroup + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceId + + {{ Fill DatasourceId Description }} + + Int32 + + Int32 + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMDeviceDatasourceInstanceGroup + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceId + + {{ Fill DatasourceId Description }} + + Int32 + + Int32 + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMDeviceDatasourceInstanceGroup + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + DatasourceName + + {{ Fill DatasourceName Description }} + + String + + String + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + Name @@ -13314,30 +14273,244 @@ Retrieves the dashboards that match the specified custom filter. None - - DatasourceId - - {{ Fill DatasourceId Description }} - - Int32 - - Int32 - - - None - - - DatasourceName - - {{ Fill DatasourceName Description }} - - String - - String - - - None - + + DatasourceId + + {{ Fill DatasourceId Description }} + + Int32 + + Int32 + + + None + + + DatasourceName + + {{ Fill DatasourceName Description }} + + String + + String + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + + + Get-LMDeviceGroupDatasourceList + Get + LMDeviceGroupDatasourceList + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-LMDeviceGroupDatasourceList + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Get-LMDeviceGroupDatasourceList + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + + + Filter + + {{ Fill Filter Description }} + + Object + + Object + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + BatchSize + + {{ Fill BatchSize Description }} + + Int32 + + Int32 + + + None + Filter @@ -13425,9 +14598,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupDatasourceList + Get-LMDeviceGroupDevices Get - LMDeviceGroupDatasourceList + LMDeviceGroupDevices {{ Fill in the Synopsis }} @@ -13437,7 +14610,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupDatasourceList + Get-LMDeviceGroupDevices BatchSize @@ -13474,6 +14647,18 @@ Retrieves the dashboards that match the specified custom filter. None + + IncludeSubGroups + + {{ Fill IncludeSubGroups Description }} + + Boolean + + Boolean + + + None + ProgressAction @@ -13488,7 +14673,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupDatasourceList + Get-LMDeviceGroupDevices BatchSize @@ -13513,7 +14698,19 @@ Retrieves the dashboards that match the specified custom filter. None - + + IncludeSubGroups + + {{ Fill IncludeSubGroups Description }} + + Boolean + + Boolean + + + None + + Name {{ Fill Name Description }} @@ -13576,7 +14773,19 @@ Retrieves the dashboards that match the specified custom filter. None - + + IncludeSubGroups + + {{ Fill IncludeSubGroups Description }} + + Boolean + + Boolean + + + None + + Name {{ Fill Name Description }} @@ -13639,9 +14848,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupDevices + Get-LMDeviceGroupGroups Get - LMDeviceGroupDevices + LMDeviceGroupGroups {{ Fill in the Synopsis }} @@ -13651,7 +14860,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupDevices + Get-LMDeviceGroupGroups BatchSize @@ -13688,18 +14897,6 @@ Retrieves the dashboards that match the specified custom filter. None - - IncludeSubGroups - - {{ Fill IncludeSubGroups Description }} - - Boolean - - Boolean - - - None - ProgressAction @@ -13714,7 +14911,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupDevices + Get-LMDeviceGroupGroups BatchSize @@ -13739,18 +14936,6 @@ Retrieves the dashboards that match the specified custom filter. None - - IncludeSubGroups - - {{ Fill IncludeSubGroups Description }} - - Boolean - - Boolean - - - None - Name @@ -13814,18 +14999,6 @@ Retrieves the dashboards that match the specified custom filter. None - - IncludeSubGroups - - {{ Fill IncludeSubGroups Description }} - - Boolean - - Boolean - - - None - Name @@ -13889,9 +15062,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupGroups + Get-LMDeviceGroupProperty Get - LMDeviceGroupGroups + LMDeviceGroupProperty {{ Fill in the Synopsis }} @@ -13901,7 +15074,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupGroups + Get-LMDeviceGroupProperty BatchSize @@ -13952,7 +15125,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupGroups + Get-LMDeviceGroupProperty BatchSize @@ -14103,9 +15276,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupProperty + Get-LMDeviceGroupSDT Get - LMDeviceGroupProperty + LMDeviceGroupSDT {{ Fill in the Synopsis }} @@ -14115,7 +15288,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupProperty + Get-LMDeviceGroupSDT BatchSize @@ -14166,7 +15339,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupProperty + Get-LMDeviceGroupSDT BatchSize @@ -14317,9 +15490,9 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupSDT + Get-LMDeviceGroupSDTHistory Get - LMDeviceGroupSDT + LMDeviceGroupSDTHistory {{ Fill in the Synopsis }} @@ -14329,7 +15502,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupSDT + Get-LMDeviceGroupSDTHistory BatchSize @@ -14380,7 +15553,7 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupSDT + Get-LMDeviceGroupSDTHistory BatchSize @@ -14531,105 +15704,78 @@ Retrieves the dashboards that match the specified custom filter. - Get-LMDeviceGroupSDTHistory + Get-LMDeviceInstanceData Get - LMDeviceGroupSDTHistory + LMDeviceInstanceData - {{ Fill in the Synopsis }} + Retrieves data for LogicMonitor device instances. - {{ Fill in the Description }} + The Get-LMDeviceInstanceData function retrieves data for LogicMonitor device instances based on the specified parameters. - Get-LMDeviceGroupSDTHistory - - BatchSize - - {{ Fill BatchSize Description }} - - Int32 - - Int32 - - - None - - - Filter - - {{ Fill Filter Description }} - - Object - - Object - - - None - - - Id + Get-LMDeviceInstanceData + + StartDate - {{ Fill Id Description }} + The start date for the data retrieval. If not specified, the function uses the default value of 24 hours ago which is the max timeframe for this endpoint. - Int32 + DateTime - Int32 + DateTime None - - ProgressAction + + EndDate - {{ Fill ProgressAction Description }} + The end date for the data retrieval. If not specified, the function uses the current date and time. - ActionPreference + DateTime - ActionPreference + DateTime None - - - Get-LMDeviceGroupSDTHistory - - BatchSize + + Ids - {{ Fill BatchSize Description }} + The array of device instance IDs for which to retrieve data. This parameter is mandatory. - Int32 + String[] - Int32 + String[] None - - Filter + + AggregationType - {{ Fill Filter Description }} + The type of aggregation to apply to the retrieved data. Valid values are "first", "last", "min", "max", "sum", "average", and "none". The default value is "none". - Object + String - Object + String None - - Name + + Period - {{ Fill Name Description }} + The period for the data retrieval. The default value is 1. - String + Double - String + Double - None + 1 ProgressAction @@ -14646,46 +15792,46 @@ Retrieves the dashboards that match the specified custom filter. - - BatchSize + + StartDate - {{ Fill BatchSize Description }} + The start date for the data retrieval. If not specified, the function uses the default value of 24 hours ago which is the max timeframe for this endpoint. - Int32 + DateTime - Int32 + DateTime None - - Filter + + EndDate - {{ Fill Filter Description }} + The end date for the data retrieval. If not specified, the function uses the current date and time. - Object + DateTime - Object + DateTime None - - Id + + Ids - {{ Fill Id Description }} + The array of device instance IDs for which to retrieve data. This parameter is mandatory. - Int32 + String[] - Int32 + String[] None - - Name + + AggregationType - {{ Fill Name Description }} + The type of aggregation to apply to the retrieved data. Valid values are "first", "last", "min", "max", "sum", "average", and "none". The default value is "none". String @@ -14694,6 +15840,18 @@ Retrieves the dashboards that match the specified custom filter. None + + Period + + The period for the data retrieval. The default value is 1. + + Double + + Double + + + 1 + ProgressAction @@ -14707,37 +15865,20 @@ Retrieves the dashboards that match the specified custom filter. None - - - - None - - - - - - - - - - System.Object - - - - - - + + - + This function requires a valid LogicMonitor API authentication. Make sure to log in using Connect-LMAccount before running this command. - -------------------------- Example 1 -------------------------- - PS C:\> {{ Add example code here }} + -------------------------- EXAMPLE 1 -------------------------- + Get-LMDeviceInstanceData -StartDate (Get-Date).AddHours(-7) -EndDate (Get-Date) -Ids "12345", "67890" -AggregationType "average" -Period 1 +Retrieves data for the device instances with IDs "12345" and "67890" for the past 7 hours, using an average aggregation and a period of 1 day. - {{ Add example description here }} + @@ -24936,6 +26077,573 @@ Invokes an active discovery task for all devices in the device group with the na + + + Invoke-LMAWSAccountTest + Invoke + LMAWSAccountTest + + Invokes a test for an AWS account in LogicMonitor. + + + + The Invoke-LMAWSAccountTest function is used to invoke a test for an AWS account in LogicMonitor. It checks if the user is logged in and has valid API credentials. If the user is logged in, it builds the necessary headers and URI, prepares the data, and sends a POST request to the LogicMonitor API to perform the test. The function returns the response from the API. + + + + Invoke-LMAWSAccountTest + + ExternalId + + The external ID of the AWS account. + + String + + String + + + None + + + AccountId + + The account ID of the AWS account. + + String + + String + + + None + + + AssumedRoleARN + + The assumed role ARN of the AWS account. + + String + + String + + + None + + + CheckedServices + + The list of services to be checked during the test. Default value is a comma-separated string of service names supported by LogicMonitor. + + String + + String + + + DYNAMODB,EBS,EC2,AUTOSCALING,BACKUP,BACKUPPROTECTEDRESOURCE,TRANSFER,ELASTICACHE,ELB,RDS,REDSHIFT,S3,SNS,SQS,EMR,KINESIS,ROUTE53,ROUTE53HOSTEDZONE,CLOUDSEARCH,LAMBDA,ECR,ECS,ELASTICSEARCH,EFS,SWFWORKFLOW,SWFACTIVITY,APPLICATIONELB,CLOUDFRONT,APIGATEWAY,APIGATEWAYV2,SES,VPN,FIREHOSE,KINESISVIDEO,WORKSPACE,NETWORKELB,NATGATEWAY,DIRECTCONNECT,DIRECTCONNECT_VIRTUALINTERFACE,WORKSPACEDIRECTORY,ELASTICBEANSTALK,DMSREPLICATION,MSKCLUSTER,MSKBROKER,FSX,TRANSITGATEWAY,GLUE,APPSTREAM,MQ,ATHENA,DBCLUSTER,DOCDB,STEPFUNCTIONS,OPSWORKS,CODEBUILD,SAGEMAKER,ROUTE53RESOLVER,DMSREPLICATIONTASKS,EVENTBRIDGE,MEDIACONNECT,MEDIAPACKAGELIVE,MEDIASTORE,MEDIAPACKAGEVOD,MEDIATAILOR,MEDIACONVERT,ELASTICTRANSCODER,COGNITO,TRANSITGATEWAYATTACHMENT,QUICKSIGHT_DASHBOARDS,QUICKSIGHT_DATASETS,PRIVATELINK_ENDPOINTS,PRIVATELINK_SERVICES,GLOBAL_NETWORKS + + + GroupId + + The device group ID to which the AWS account belongs. Default value is -1 for no group. + + String + + String + + + -1 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ExternalId + + The external ID of the AWS account. + + String + + String + + + None + + + AccountId + + The account ID of the AWS account. + + String + + String + + + None + + + AssumedRoleARN + + The assumed role ARN of the AWS account. + + String + + String + + + None + + + CheckedServices + + The list of services to be checked during the test. Default value is a comma-separated string of service names supported by LogicMonitor. + + String + + String + + + DYNAMODB,EBS,EC2,AUTOSCALING,BACKUP,BACKUPPROTECTEDRESOURCE,TRANSFER,ELASTICACHE,ELB,RDS,REDSHIFT,S3,SNS,SQS,EMR,KINESIS,ROUTE53,ROUTE53HOSTEDZONE,CLOUDSEARCH,LAMBDA,ECR,ECS,ELASTICSEARCH,EFS,SWFWORKFLOW,SWFACTIVITY,APPLICATIONELB,CLOUDFRONT,APIGATEWAY,APIGATEWAYV2,SES,VPN,FIREHOSE,KINESISVIDEO,WORKSPACE,NETWORKELB,NATGATEWAY,DIRECTCONNECT,DIRECTCONNECT_VIRTUALINTERFACE,WORKSPACEDIRECTORY,ELASTICBEANSTALK,DMSREPLICATION,MSKCLUSTER,MSKBROKER,FSX,TRANSITGATEWAY,GLUE,APPSTREAM,MQ,ATHENA,DBCLUSTER,DOCDB,STEPFUNCTIONS,OPSWORKS,CODEBUILD,SAGEMAKER,ROUTE53RESOLVER,DMSREPLICATIONTASKS,EVENTBRIDGE,MEDIACONNECT,MEDIAPACKAGELIVE,MEDIASTORE,MEDIAPACKAGEVOD,MEDIATAILOR,MEDIACONVERT,ELASTICTRANSCODER,COGNITO,TRANSITGATEWAYATTACHMENT,QUICKSIGHT_DASHBOARDS,QUICKSIGHT_DATASETS,PRIVATELINK_ENDPOINTS,PRIVATELINK_SERVICES,GLOBAL_NETWORKS + + + GroupId + + The device group ID to which the AWS account belongs. Default value is -1 for no group. + + String + + String + + + -1 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + This function requires the user to be logged in before running any commands. Use the Connect-LMAccount function to log in before invoking this function. + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-LMAWSAccountTest -ExternalId "123456" -AccountId "987654" -AccessId "AKI123" -AccessKey "abc123" -AssumedRoleARN "arn:aws:iam::123456789012:role/MyRole" -CheckedServices "EC2,S3,RDS" -GroupId 123 + + This example invokes a test for an AWS account with the specified parameters. + + + + + + + + Invoke-LMAzureAccountTest + Invoke + LMAzureAccountTest + + Invokes a test on an Azure account. + + + + The Invoke-LMAzureAccountTest function is used to invoke a test on an Azure account. It checks if the user is logged in and has valid API credentials. If the user is logged in, it builds the necessary headers and URI, and then sends a POST request to the specified endpoint. The function returns the response from the API. + + + + Invoke-LMAzureAccountTest + + ClientId + + The client ID of the Azure account. + + String + + String + + + None + + + SecretKey + + The secret key of the Azure account. + + String + + String + + + None + + + CheckedServices + + The list of services to be checked. Default value is a list of commonly used Azure services. + + String + + String + + + VIRTUALMACHINE,SQLDATABASE,APPSERVICE,EVENTHUB,REDISCACHE,REDISCACHEENTERPRISE,VIRTUALMACHINESCALESET,VIRTUALMACHINESCALESETVM,APPLICATIONGATEWAY,IOTHUB,FUNCTION,SERVICEBUS,MARIADB,MYSQL,MYSQLFLEXIBLE,POSTGRESQL,POSTGRESQLFLEXIBLE,POSTGRESQLCITUS,ANALYSISSERVICE,TABLESTORAGE,BLOBSTORAGE,FILESTORAGE,QUEUESTORAGE,STORAGEACCOUNT,APIMANAGEMENT,COSMOSDB,APPSERVICEPLAN,VIRTUALNETWORKGATEWAY,AUTOMATIONACCOUNT,EXPRESSROUTECIRCUIT,DATALAKEANALYTICS,DATALAKESTORE,APPLICATIONINSIGHTS,FIREWALL,SQLELASTICPOOL,SQLMANAGEDINSTANCE,HDINSIGHT,RECOVERYSERVICES,BACKUPPROTECTEDITEMS,RECOVERYPROTECTEDITEMS,NETWORKINTERFACE,BATCHACCOUNT,LOGICAPPS,DATAFACTORY,PUBLICIP,STREAMANALYTICS,EVENTGRID,LOADBALANCERS,SERVICEFABRICMESH,COGNITIVESEARCH,COGNITIVESERVICES,MLWORKSPACES,FRONTDOORS,KEYVAULT,RELAYNAMESPACES,NOTIFICATIONHUBS,APPSERVICEENVIRONMENT,TRAFFICMANAGER,SIGNALR,VIRTUALDESKTOP,SYNAPSEWORKSPACES,NETAPPPOOLS,DATABRICKS,LOGANALYTICSWORKSPACES,VIRTUALHUBS,VPNGATEWAYS,CDNPROFILE,POWERBIEMBEDDED,CONTAINERREGISTRY,NATGATEWAYS,BOTSERVICES,VIRTUALNETWORKS + + + SubscriptionIds + + The subscription IDs associated with the Azure account. + + String + + String + + + None + + + GroupId + + The group ID. Default value is -1. + + String + + String + + + -1 + + + TenantId + + The tenant ID of the Azure account. + + String + + String + + + None + + + IsChinaAccount + + Specifies whether the Azure account is a China account. Default value is $false. + + String + + String + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ClientId + + The client ID of the Azure account. + + String + + String + + + None + + + SecretKey + + The secret key of the Azure account. + + String + + String + + + None + + + CheckedServices + + The list of services to be checked. Default value is a list of commonly used Azure services. + + String + + String + + + VIRTUALMACHINE,SQLDATABASE,APPSERVICE,EVENTHUB,REDISCACHE,REDISCACHEENTERPRISE,VIRTUALMACHINESCALESET,VIRTUALMACHINESCALESETVM,APPLICATIONGATEWAY,IOTHUB,FUNCTION,SERVICEBUS,MARIADB,MYSQL,MYSQLFLEXIBLE,POSTGRESQL,POSTGRESQLFLEXIBLE,POSTGRESQLCITUS,ANALYSISSERVICE,TABLESTORAGE,BLOBSTORAGE,FILESTORAGE,QUEUESTORAGE,STORAGEACCOUNT,APIMANAGEMENT,COSMOSDB,APPSERVICEPLAN,VIRTUALNETWORKGATEWAY,AUTOMATIONACCOUNT,EXPRESSROUTECIRCUIT,DATALAKEANALYTICS,DATALAKESTORE,APPLICATIONINSIGHTS,FIREWALL,SQLELASTICPOOL,SQLMANAGEDINSTANCE,HDINSIGHT,RECOVERYSERVICES,BACKUPPROTECTEDITEMS,RECOVERYPROTECTEDITEMS,NETWORKINTERFACE,BATCHACCOUNT,LOGICAPPS,DATAFACTORY,PUBLICIP,STREAMANALYTICS,EVENTGRID,LOADBALANCERS,SERVICEFABRICMESH,COGNITIVESEARCH,COGNITIVESERVICES,MLWORKSPACES,FRONTDOORS,KEYVAULT,RELAYNAMESPACES,NOTIFICATIONHUBS,APPSERVICEENVIRONMENT,TRAFFICMANAGER,SIGNALR,VIRTUALDESKTOP,SYNAPSEWORKSPACES,NETAPPPOOLS,DATABRICKS,LOGANALYTICSWORKSPACES,VIRTUALHUBS,VPNGATEWAYS,CDNPROFILE,POWERBIEMBEDDED,CONTAINERREGISTRY,NATGATEWAYS,BOTSERVICES,VIRTUALNETWORKS + + + SubscriptionIds + + The subscription IDs associated with the Azure account. + + String + + String + + + None + + + GroupId + + The group ID. Default value is -1. + + String + + String + + + -1 + + + TenantId + + The tenant ID of the Azure account. + + String + + String + + + None + + + IsChinaAccount + + Specifies whether the Azure account is a China account. Default value is $false. + + String + + String + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-LMAzureAccountTest -ClientId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SecretKey "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SubscriptionIds "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + + This example invokes a test on an Azure account using the specified client ID, secret key, and subscription IDs. + + + + + + + + Invoke-LMAzureSubscriptionDiscovery + Invoke + LMAzureSubscriptionDiscovery + + Invokes the Azure subscription discovery process to return subscriptions for a specified client Id. + + + + The Invoke-LMAzureSubscriptionDiscovery function is used to discover Azure subscriptions by making API requests to the LogicMonitor platform. + + + + Invoke-LMAzureSubscriptionDiscovery + + ClientId + + The client ID of the Azure Active Directory application. + + String + + String + + + None + + + SecretKey + + The secret key of the Azure Active Directory application. + + String + + String + + + None + + + TenantId + + The tenant ID of the Azure Active Directory application. + + String + + String + + + None + + + IsChinaAccount + + Specifies whether the Azure account is a China account. Default value is $false. + + String + + String + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ClientId + + The client ID of the Azure Active Directory application. + + String + + String + + + None + + + SecretKey + + The secret key of the Azure Active Directory application. + + String + + String + + + None + + + TenantId + + The tenant ID of the Azure Active Directory application. + + String + + String + + + None + + + IsChinaAccount + + Specifies whether the Azure account is a China account. Default value is $false. + + String + + String + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-LMAzureSubscriptionDiscovery -ClientId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SecretKey "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + + + + + + + Invoke-LMCloudGroupNetScan @@ -26105,6 +27813,163 @@ Schedules a configuration collection task for the device with the ID 123, the da + + + Invoke-LMGCPAccountTest + Invoke + LMGCPAccountTest + + Invokes a test for a GCP (Google Cloud Platform) account. + + + + The Invoke-LMGCPAccountTest function is used to invoke a test for a GCP account. It checks if the user is logged in and has valid API credentials. If the user is logged in, it builds the necessary headers and URI, prepares the data, and sends a POST request to the LogicMonitor API to perform the test. The function returns the response from the API. + + + + Invoke-LMGCPAccountTest + + ServiceAccountKey + + The service account key for the GCP account. + + String + + String + + + None + + + ProjectId + + The ID of the GCP project. + + String + + String + + + None + + + CheckedServices + + (Optional) A comma-separated list of GCP services to be checked. The default value is a list of all LM supported GCP services. + + String + + String + + + CLOUDRUN,CLOUDDNS,REGIONALHTTPSLOADBALANCER,COMPUTEENGINEAUTOSCALER,COMPUTEENGINE,CLOUDIOT,CLOUDROUTER,CLOUDTASKS,VPNGATEWAY,CLOUDREDIS,CLOUDCOMPOSER,INTERCONNECTATTACHMENT,CLOUDFUNCTION,CLOUDBIGTABLE,CLOUDFILESTORE,CLOUDPUBSUB,CLOUDTRACE,CLOUDSTORAGE,CLOUDDATAPROC,CLOUDINTERCONNECT,CLOUDAIPLATFORM,CLOUDSQL,MANAGEDSERVICEFORMICROSOFTAD,CLOUDFIRESTORE,CLOUDDATAFLOW,CLOUDTPU,CLOUDDLP,APPENGINE,HTTPSLOADBALANCER,CLOUDSPANNER + + + GroupId + + (Optional) The ID of the group to which the GCP account belongs. The default value is -1, indicating no group. + + String + + String + + + -1 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + ServiceAccountKey + + The service account key for the GCP account. + + String + + String + + + None + + + ProjectId + + The ID of the GCP project. + + String + + String + + + None + + + CheckedServices + + (Optional) A comma-separated list of GCP services to be checked. The default value is a list of all LM supported GCP services. + + String + + String + + + CLOUDRUN,CLOUDDNS,REGIONALHTTPSLOADBALANCER,COMPUTEENGINEAUTOSCALER,COMPUTEENGINE,CLOUDIOT,CLOUDROUTER,CLOUDTASKS,VPNGATEWAY,CLOUDREDIS,CLOUDCOMPOSER,INTERCONNECTATTACHMENT,CLOUDFUNCTION,CLOUDBIGTABLE,CLOUDFILESTORE,CLOUDPUBSUB,CLOUDTRACE,CLOUDSTORAGE,CLOUDDATAPROC,CLOUDINTERCONNECT,CLOUDAIPLATFORM,CLOUDSQL,MANAGEDSERVICEFORMICROSOFTAD,CLOUDFIRESTORE,CLOUDDATAFLOW,CLOUDTPU,CLOUDDLP,APPENGINE,HTTPSLOADBALANCER,CLOUDSPANNER + + + GroupId + + (Optional) The ID of the group to which the GCP account belongs. The default value is -1, indicating no group. + + String + + String + + + -1 + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + This function requires the user to be logged in before running any commands. Use the Connect-LMAccount function to log in before invoking this function. + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-LMGCPAccountTest -ServiceAccountKey "service-account-key" -ProjectId "project-id" + + This example invokes a test for a GCP account using the specified service account key and project ID. + + + + + Invoke-LMNetScan @@ -26277,6 +28142,157 @@ Invokes a session logoff for the users "user1" and "user2" in Logic Monitor. + + + New-LMAccessGroup + New + LMAccessGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + New-LMAccessGroup + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + Description + + {{ Fill Description Description }} + + String + + String + + + None + + + Tenant + + {{ Fill Tenant Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Description + + {{ Fill Description Description }} + + String + + String + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + Tenant + + {{ Fill Tenant Description }} + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + New-LMAlertAck @@ -26386,6 +28402,92 @@ Invokes a session logoff for the users "user1" and "user2" in Logic Monitor. + + + New-LMAlertEscalation + New + LMAlertEscalation + + Creates a new escalation for a LogicMonitor alert. + + + + The New-LMAlertEscalation function creates a new escalation for a LogicMonitor alert. It checks if the user is logged in and has valid API credentials before making the API request to create the escalation. + + + + New-LMAlertEscalation + + Id + + The ID of the alert for which the escalation needs to be created. + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Id + + The ID of the alert for which the escalation needs to be created. + + String + + String + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + New-LMAlertEscalation -Id "DS12345" +Creates a new escalation for the alert with ID "12345". + + + + + + + New-LMAlertNote @@ -38376,6 +40478,216 @@ Creates a new network scan with the specified collector ID, name, and subnet ran + + + Remove-LMAccessGroup + Remove + LMAccessGroup + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Remove-LMAccessGroup + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Remove-LMAccessGroup + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Id + + {{ Fill Id Description }} + + Int32 + + Int32 + + + None + + + Name + + {{ Fill Name Description }} + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + System.Int32 + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + Remove-LMAPIToken @@ -44763,22 +47075,398 @@ Removes the LogicMonitor role with the Name "Admin". - + + + + + + -------------------------- EXAMPLE 1 -------------------------- + Send-LMLogMessage -Message "This is a test log message" -resourceMapping @{ 'system.deviceId' = '12345' } -Metadata @{ 'key1' = 'value1'; 'key2' = 'value2' } + + Sends a single log message with the specified message, resource mapping, and metadata. + + + + -------------------------- EXAMPLE 2 -------------------------- + Send-LMLogMessage -MessageArray $MessageObjectsArray + + Sends an array of log message objects. + + + + + + + + Send-LMPushMetric + Send + LMPushMetric + + Sends a push metric to LogicMonitor. + + + + The Send-LMPushMetric function sends a push metric to LogicMonitor. It allows you to create a new resource or update an existing resource with the specified metric data. + + + + Send-LMPushMetric + + NewResourceHostName + + Specifies the hostname of the new resource to be created. This parameter is required if you want to create a new resource. + + String + + String + + + None + + + NewResourceDescription + + Specifies the description of the new resource to be created. This parameter is required if you want to create a new resource. + + String + + String + + + None + + + ResourceIds + + Specifies the resource IDs to use for resource mapping. This parameter is mandatory. + + Hashtable + + Hashtable + + + None + + + ResourceProperties + + Specifies the properties of the resources to be updated. This parameter is optional. + + Hashtable + + Hashtable + + + None + + + DatasourceId + + Specifies the ID of the datasource. This parameter is required if the datasource name is not specified. + + String + + String + + + None + + + DatasourceDisplayName + + Specifies the display name of the datasource. This parameter is optional and defaults to the datasource name if not specified. + + String + + String + + + None + + + DatasourceGroup + + Specifies the group of the datasource. This parameter is optional and defaults to "PushModules" if not specified. + + String + + String + + + None + + + Instances + + Specifies the instances of the resources to be updated. This parameter is mandatory. The instances should be the results of the New-LMPushMetricInstance function. + + System.Collections.Generic.List`1[System.Object] + + System.Collections.Generic.List`1[System.Object] + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Send-LMPushMetric + + NewResourceHostName + + Specifies the hostname of the new resource to be created. This parameter is required if you want to create a new resource. + + String + + String + + + None + + + NewResourceDescription + + Specifies the description of the new resource to be created. This parameter is required if you want to create a new resource. + + String + + String + + + None + + + ResourceIds + + Specifies the resource IDs to use for resource mapping. This parameter is mandatory. + + Hashtable + + Hashtable + + + None + + + ResourceProperties + + Specifies the properties of the resources to be updated. This parameter is optional. + + Hashtable + + Hashtable + + + None + + + DatasourceName + + Specifies the name of the datasource. This parameter is required if the datasource ID is not specified. + + String + + String + + + None + + + DatasourceDisplayName + + Specifies the display name of the datasource. This parameter is optional and defaults to the datasource name if not specified. + + String + + String + + + None + + + DatasourceGroup + + Specifies the group of the datasource. This parameter is optional and defaults to "PushModules" if not specified. + + String + + String + + + None + + + Instances + + Specifies the instances of the resources to be updated. This parameter is mandatory. The instances should be the results of the New-LMPushMetricInstance function. + + System.Collections.Generic.List`1[System.Object] + + System.Collections.Generic.List`1[System.Object] + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + NewResourceHostName + + Specifies the hostname of the new resource to be created. This parameter is required if you want to create a new resource. + + String + + String + + + None + + + NewResourceDescription + + Specifies the description of the new resource to be created. This parameter is required if you want to create a new resource. + + String + + String + + + None + + + ResourceIds + + Specifies the resource IDs to use for resource mapping. This parameter is mandatory. + + Hashtable + + Hashtable + + + None + + + ResourceProperties + + Specifies the properties of the resources to be updated. This parameter is optional. + + Hashtable + + Hashtable + + + None + + + DatasourceId + + Specifies the ID of the datasource. This parameter is required if the datasource name is not specified. + + String + + String + + + None + + + DatasourceName + + Specifies the name of the datasource. This parameter is required if the datasource ID is not specified. + + String + + String + + + None + + + DatasourceDisplayName + + Specifies the display name of the datasource. This parameter is optional and defaults to the datasource name if not specified. + + String + + String + + + None + + + DatasourceGroup + + Specifies the group of the datasource. This parameter is optional and defaults to "PushModules" if not specified. + + String + + String + + + None + + + Instances + + Specifies the instances of the resources to be updated. This parameter is mandatory. The instances should be the results of the New-LMPushMetricInstance function. + + System.Collections.Generic.List`1[System.Object] + + System.Collections.Generic.List`1[System.Object] + + + None + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + + This function requires a valid API authentication. Make sure you are logged in before running any commands using Connect-LMAccount. -------------------------- EXAMPLE 1 -------------------------- - Send-LMLogMessage -Message "This is a test log message" -resourceMapping @{ 'system.deviceId' = '12345' } -Metadata @{ 'key1' = 'value1'; 'key2' = 'value2' } - - Sends a single log message with the specified message, resource mapping, and metadata. - - - - -------------------------- EXAMPLE 2 -------------------------- - Send-LMLogMessage -MessageArray $MessageObjectsArray + Send-LMPushMetric -NewResourceHostName "NewResource" -NewResourceDescription "New Resource Description" -ResourceIds @{"system.deviceId"="12345"} -ResourceProperties @{"Property1"="Value1"; "Property2"="Value2"} -DatasourceId "123" -Instances $Instances - Sends an array of log message objects. + This example sends a push metric to LogicMonitor by creating a new resource with the specified hostname and description. It updates the resource properties and associates it with the specified datasource ID. The metric data is sent for the specified instances. @@ -44786,35 +47474,23 @@ Removes the LogicMonitor role with the Name "Admin". - Send-LMPushMetric - Send - LMPushMetric + Set-LMAccessGroup + Set + LMAccessGroup - Sends a push metric to LogicMonitor. + {{ Fill in the Synopsis }} - The Send-LMPushMetric function sends a push metric to LogicMonitor. It allows you to create a new resource or update an existing resource with the specified metric data. + {{ Fill in the Description }} - Send-LMPushMetric - - NewResourceHostName - - Specifies the hostname of the new resource to be created. This parameter is required if you want to create a new resource. - - String - - String - - - None - + Set-LMAccessGroup - NewResourceDescription + Description - Specifies the description of the new resource to be created. This parameter is required if you want to create a new resource. + {{ Fill Description Description }} String @@ -44823,46 +47499,22 @@ Removes the LogicMonitor role with the Name "Admin". None - - ResourceIds - - Specifies the resource IDs to use for resource mapping. This parameter is mandatory. - - Hashtable - - Hashtable - - - None - - - ResourceProperties - - Specifies the properties of the resources to be updated. This parameter is optional. - - Hashtable - - Hashtable - - - None - - - DatasourceId + + Id - Specifies the ID of the datasource. This parameter is required if the datasource name is not specified. + {{ Fill Id Description }} - String + Int32 - String + Int32 None - DatasourceDisplayName + NewName - Specifies the display name of the datasource. This parameter is optional and defaults to the datasource name if not specified. + {{ Fill NewName Description }} String @@ -44872,9 +47524,9 @@ Removes the LogicMonitor role with the Name "Admin". None - DatasourceGroup + Tenant - Specifies the group of the datasource. This parameter is optional and defaults to "PushModules" if not specified. + {{ Fill Tenant Description }} String @@ -44883,18 +47535,6 @@ Removes the LogicMonitor role with the Name "Admin". None - - Instances - - Specifies the instances of the resources to be updated. This parameter is mandatory. The instances should be the results of the New-LMPushMetricInstance function. - - System.Collections.Generic.List`1[System.Object] - - System.Collections.Generic.List`1[System.Object] - - - None - ProgressAction @@ -44909,23 +47549,11 @@ Removes the LogicMonitor role with the Name "Admin". - Send-LMPushMetric - - NewResourceHostName - - Specifies the hostname of the new resource to be created. This parameter is required if you want to create a new resource. - - String - - String - - - None - + Set-LMAccessGroup - NewResourceDescription + Description - Specifies the description of the new resource to be created. This parameter is required if you want to create a new resource. + {{ Fill Description Description }} String @@ -44934,34 +47562,10 @@ Removes the LogicMonitor role with the Name "Admin". None - - ResourceIds - - Specifies the resource IDs to use for resource mapping. This parameter is mandatory. - - Hashtable - - Hashtable - - - None - - ResourceProperties - - Specifies the properties of the resources to be updated. This parameter is optional. - - Hashtable - - Hashtable - - - None - - - DatasourceName + Name - Specifies the name of the datasource. This parameter is required if the datasource ID is not specified. + {{ Fill Name Description }} String @@ -44971,9 +47575,9 @@ Removes the LogicMonitor role with the Name "Admin". None - DatasourceDisplayName + NewName - Specifies the display name of the datasource. This parameter is optional and defaults to the datasource name if not specified. + {{ Fill NewName Description }} String @@ -44983,9 +47587,9 @@ Removes the LogicMonitor role with the Name "Admin". None - DatasourceGroup + Tenant - Specifies the group of the datasource. This parameter is optional and defaults to "PushModules" if not specified. + {{ Fill Tenant Description }} String @@ -44994,18 +47598,6 @@ Removes the LogicMonitor role with the Name "Admin". None - - Instances - - Specifies the instances of the resources to be updated. This parameter is mandatory. The instances should be the results of the New-LMPushMetricInstance function. - - System.Collections.Generic.List`1[System.Object] - - System.Collections.Generic.List`1[System.Object] - - - None - ProgressAction @@ -45022,21 +47614,9 @@ Removes the LogicMonitor role with the Name "Admin". - NewResourceHostName - - Specifies the hostname of the new resource to be created. This parameter is required if you want to create a new resource. - - String - - String - - - None - - - NewResourceDescription + Description - Specifies the description of the new resource to be created. This parameter is required if you want to create a new resource. + {{ Fill Description Description }} String @@ -45045,46 +47625,22 @@ Removes the LogicMonitor role with the Name "Admin". None - - ResourceIds + + Id - Specifies the resource IDs to use for resource mapping. This parameter is mandatory. + {{ Fill Id Description }} - Hashtable + Int32 - Hashtable + Int32 None - ResourceProperties - - Specifies the properties of the resources to be updated. This parameter is optional. - - Hashtable - - Hashtable - - - None - - - DatasourceId - - Specifies the ID of the datasource. This parameter is required if the datasource name is not specified. - - String - - String - - - None - - - DatasourceName + Name - Specifies the name of the datasource. This parameter is required if the datasource ID is not specified. + {{ Fill Name Description }} String @@ -45094,9 +47650,9 @@ Removes the LogicMonitor role with the Name "Admin". None - DatasourceDisplayName + NewName - Specifies the display name of the datasource. This parameter is optional and defaults to the datasource name if not specified. + {{ Fill NewName Description }} String @@ -45106,9 +47662,9 @@ Removes the LogicMonitor role with the Name "Admin". None - DatasourceGroup + Tenant - Specifies the group of the datasource. This parameter is optional and defaults to "PushModules" if not specified. + {{ Fill Tenant Description }} String @@ -45117,18 +47673,6 @@ Removes the LogicMonitor role with the Name "Admin". None - - Instances - - Specifies the instances of the resources to be updated. This parameter is mandatory. The instances should be the results of the New-LMPushMetricInstance function. - - System.Collections.Generic.List`1[System.Object] - - System.Collections.Generic.List`1[System.Object] - - - None - ProgressAction @@ -45142,19 +47686,37 @@ Removes the LogicMonitor role with the Name "Admin". None - - + + + + System.Int32 + + + + + + + + + + System.Object + + + + + + - This function requires a valid API authentication. Make sure you are logged in before running any commands using Connect-LMAccount. + - -------------------------- EXAMPLE 1 -------------------------- - Send-LMPushMetric -NewResourceHostName "NewResource" -NewResourceDescription "New Resource Description" -ResourceIds @{"system.deviceId"="12345"} -ResourceProperties @{"Property1"="Value1"; "Property2"="Value2"} -DatasourceId "123" -Instances $Instances + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} - This example sends a push metric to LogicMonitor by creating a new resource with the specified hostname and description. It updates the resource properties and associates it with the specified datasource ID. The metric data is sent for the specified instances. + {{ Add example description here }} @@ -48861,6 +51423,18 @@ Removes the LogicMonitor role with the Name "Admin". Set-LMDevice + + AutoBalancedCollectorGroupId + + {{ Fill AutoBalancedCollectorGroupId Description }} + + Int32 + + Int32 + + + None + Confirm @@ -49095,6 +51669,18 @@ Removes the LogicMonitor role with the Name "Admin". Set-LMDevice + + AutoBalancedCollectorGroupId + + {{ Fill AutoBalancedCollectorGroupId Description }} + + Int32 + + Int32 + + + None + Confirm @@ -49329,6 +51915,18 @@ Removes the LogicMonitor role with the Name "Admin". + + AutoBalancedCollectorGroupId + + {{ Fill AutoBalancedCollectorGroupId Description }} + + Int32 + + Int32 + + + None + Confirm @@ -59559,6 +62157,269 @@ Removes the LogicMonitor role with the Name "Admin". + + + Set-LMUserdata + Set + LMUserdata + + Sets userdata for a LogicMonitor user. Currently only setting the default dashboard is supported. + + + + The Set-LMUserdata function is used to set the user data for a LogicMonitor user. It allows you to specify the user by either their Id or Name, and the dashboard Id for which the user data should be set. + + + + Set-LMUserdata + + Id + + Specifies the Id of the user. This parameter is mandatory when using the 'Id' parameter set. + + String + + String + + + None + + + DashboardId + + Specifies the Id of the dashboard for which the user data should be set. This parameter is mandatory. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + Set-LMUserdata + + Name + + Specifies the Name of the user. This parameter is mandatory when using the 'Name' parameter set. + + String + + String + + + None + + + DashboardId + + Specifies the Id of the dashboard for which the user data should be set. This parameter is mandatory. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + Id + + Specifies the Id of the user. This parameter is mandatory when using the 'Id' parameter set. + + String + + String + + + None + + + Name + + Specifies the Name of the user. This parameter is mandatory when using the 'Name' parameter set. + + String + + String + + + None + + + DashboardId + + Specifies the Id of the dashboard for which the user data should be set. This parameter is mandatory. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + ProgressAction + + {{ Fill ProgressAction Description }} + + ActionPreference + + ActionPreference + + + None + + + + + + None. + + + + + + + + + + System.Object + + + + + + + + Returns the response from the LogicMonitor API. + + + + + + + + + This function requires a valid API authentication. Make sure you are logged in before running any commands using Connect-LMAccount. + + + + + -------------------------- EXAMPLE 1 -------------------------- + Set-LMUserdata -Id "12345" -DashboardId "67890" +Sets the user data for the user with Id "12345" for the dashboard with Id "67890". + + + + + + -------------------------- EXAMPLE 2 -------------------------- + Set-LMUserdata -Name "JohnDoe" -DashboardId "67890" +Sets the user data for the user with Name "JohnDoe" for the dashboard with Id "67890". + + + + + + + Set-LMWebsite From 46fd1493627b014eb20b2ed59f562206923cca94 Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:42:55 -0400 Subject: [PATCH 4/6] Prep release --- Public/Get-LMDeviceDataSourceList.ps1 | 53 ++++++++ Public/Get-LMDeviceDatasourceInstance.ps1 | 56 ++++++-- ...eviceDatasourceInstanceAlertRecipients.ps1 | 39 +++++- ...LMDeviceDatasourceInstanceAlertSetting.ps1 | 42 ++++++ .../Get-LMDeviceDatasourceInstanceGroup.ps1 | 44 ++++++ Public/New-LMDeviceDatasourceInstance.ps1 | 2 + .../New-LMDeviceDatasourceInstanceGroup.ps1 | 2 + Public/Remove-LMDeviceDatasourceInstance.ps1 | 30 ++-- ...Remove-LMDeviceDatasourceInstanceGroup.ps1 | 128 ++++++++++++++++++ Public/Set-LMDeviceDatasourceInstance.ps1 | 83 ++++++++++-- RELEASENOTES.md | 13 ++ 11 files changed, 458 insertions(+), 34 deletions(-) create mode 100644 Public/Remove-LMDeviceDatasourceInstanceGroup.ps1 diff --git a/Public/Get-LMDeviceDataSourceList.ps1 b/Public/Get-LMDeviceDataSourceList.ps1 index 447f55d..61e013c 100644 --- a/Public/Get-LMDeviceDataSourceList.ps1 +++ b/Public/Get-LMDeviceDataSourceList.ps1 @@ -1,11 +1,64 @@ +<# +.SYNOPSIS +Retrieves a list of device data sources from LogicMonitor. + +.DESCRIPTION +The Get-LMDeviceDatasourceList function retrieves a list of device data sources from LogicMonitor based on the specified parameters. It supports filtering by device ID or device name, and allows customization of the batch size for pagination. + +.PARAMETER Id +Specifies the ID of the device for which to retrieve the data sources. This parameter is mandatory when using the 'Id' parameter set. + +.PARAMETER Name +Specifies the name of the device for which to retrieve the data sources. This parameter is mandatory when using the 'Name' parameter set. + +.PARAMETER Filter +Specifies additional filters to apply to the data sources. This parameter accepts an object representing the filter criteria. + +.PARAMETER BatchSize +Specifies the number of data sources to retrieve per batch. The default value is 1000. + +.EXAMPLE +Get-LMDeviceDatasourceList -Id 1234 +Retrieves the data sources for the device with ID 1234. + +.EXAMPLE +Get-LMDeviceDatasourceList -Name "MyDevice" +Retrieves the data sources for the device with the name "MyDevice". + +.EXAMPLE +Get-LMDeviceDatasourceList -Filter "Property -eq 'Value'" +Retrieves the data sources that match the specified filter criteria. + +#> +Function Get-LMDeviceDatasourceList { + [CmdletBinding(DefaultParameterSetName = 'Id')] + Param ( + [Parameter(Mandatory, ParameterSetName = 'Id')] + [Alias('DeviceId')] + [Int]$Id, + + [Parameter(ParameterSetName = 'Name')] + [Alias('DeviceName')] + [String]$Name, + + [Object]$Filter, + + [ValidateRange(1, 1000)] + [Int]$BatchSize = 1000 + ) + # Rest of the code... +} + Function Get-LMDeviceDatasourceList { [CmdletBinding(DefaultParameterSetName = 'Id')] Param ( [Parameter(Mandatory, ParameterSetName = 'Id')] + [Alias('DeviceId')] [Int]$Id, [Parameter(ParameterSetName = 'Name')] + [Alias('DeviceName')] [String]$Name, [Object]$Filter, diff --git a/Public/Get-LMDeviceDatasourceInstance.ps1 b/Public/Get-LMDeviceDatasourceInstance.ps1 index 1ff9ebf..de33c7e 100644 --- a/Public/Get-LMDeviceDatasourceInstance.ps1 +++ b/Public/Get-LMDeviceDatasourceInstance.ps1 @@ -1,3 +1,39 @@ +<# +.SYNOPSIS +Retrieves instances of a LogicMonitor device datasource. + +.DESCRIPTION +The Get-LMDeviceDatasourceInstance function retrieves instances of a LogicMonitor device datasource based on the specified parameters. It requires a valid API authentication and authorization. + +.PARAMETER DatasourceName +Specifies the name of the datasource. This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. + +.PARAMETER DatasourceId +Specifies the ID of the datasource. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. + +.PARAMETER Id +Specifies the ID of the device. This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. It can also be specified using the 'DeviceId' alias. + +.PARAMETER Name +Specifies the name of the device. This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. It can also be specified using the 'DeviceName' alias. + +.PARAMETER Filter +Specifies additional filters to apply to the instances. This parameter accepts an object representing the filter criteria. + +.PARAMETER BatchSize +Specifies the number of instances to retrieve per batch. The default value is 1000. + +.EXAMPLE +Get-LMDeviceDatasourceInstance -DatasourceName "CPU" -Name "Server01" -BatchSize 500 +Retrieves instances of the "CPU" datasource for the device named "Server01" with a batch size of 500. + +.EXAMPLE +Get-LMDeviceDatasourceInstance -DatasourceId 1234 -Id 5678 +Retrieves instances of the datasource with ID 1234 for the device with ID 5678. + +.NOTES +This function requires a valid API authentication and authorization. Use Connect-LMAccount to log in before running any commands. +#> Function Get-LMDeviceDatasourceInstance { [CmdletBinding()] @@ -12,13 +48,13 @@ Function Get-LMDeviceDatasourceInstance { [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] - [Alias("Id")] - [Int]$DeviceId, + [Alias("DeviceId")] + [Int]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] - [Alias("Name")] - [String]$DeviceName, + [Alias("DeviceName")] + [String]$Name, [Object]$Filter, @@ -30,17 +66,17 @@ Function Get-LMDeviceDatasourceInstance { If ($Script:LMAuth.Valid) { #Lookup Device Id - If ($DeviceName) { - $LookupResult = (Get-LMDevice -Name $DeviceName).Id - If (Test-LookupResult -Result $LookupResult -LookupString $DeviceName) { + If ($Name) { + $LookupResult = (Get-LMDevice -Name $Name).Id + If (Test-LookupResult -Result $LookupResult -LookupString $Name) { return } - $DeviceId = $LookupResult + $Id = $LookupResult } #Lookup DatasourceId If ($DatasourceName -or $DatasourceId) { - $LookupResult = (Get-LMDeviceDataSourceList -Id $DeviceId | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id + $LookupResult = (Get-LMDeviceDataSourceList -Id $Id | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id If (Test-LookupResult -Result $LookupResult -LookupString $DatasourceName) { return } @@ -48,7 +84,7 @@ Function Get-LMDeviceDatasourceInstance { } #Build header and uri - $ResourcePath = "/device/devices/$DeviceId/devicedatasources/$HdsId/instances" + $ResourcePath = "/device/devices/$Id/devicedatasources/$HdsId/instances" #Initalize vars $QueryParams = "" diff --git a/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 b/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 index 8e2ffe0..d7059c2 100644 --- a/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 @@ -1,5 +1,40 @@ -Function Get-LMDeviceDatasourceInstanceAlertRecipients { +<# +.SYNOPSIS +Retrieves the alert recipients for a specific data point in a LogicMonitor device datasource instance. + +.DESCRIPTION +The Get-LMDeviceDatasourceInstanceAlertRecipients function retrieves the alert recipients for a specific data point in a LogicMonitor device datasource instance. It requires valid API credentials and a logged-in session. + +.PARAMETER DatasourceName +Specifies the name of the datasource. This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. + +.PARAMETER DatasourceId +Specifies the ID of the datasource. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. + +.PARAMETER Id +Specifies the ID of the device. This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. It can also be specified using the 'DeviceId' alias. + +.PARAMETER Name +Specifies the name of the device. This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. It can also be specified using the 'DeviceName' alias. + +.PARAMETER InstanceName +Specifies the name of the datasource instance. This parameter is mandatory. +.PARAMETER DataPointName +Specifies the name of the data point. This parameter is mandatory. + +.EXAMPLE +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceName "Ping-" -Name "Server01" -InstanceName "Instance01" -DataPointName "PingLossPercent" + +Retrieves the alert recipients for the "PingLossPercent" data point in the "CPU" datasource instance of the "Server01" device. + +.EXAMPLE +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceId 123 -Id 456 -InstanceName "Instance01" -DataPointName "PingLossPercent" + +Retrieves the alert recipients for the "PingLossPercent" data point in the datasource instance with ID 123 of the device with ID 456. + +#> +Function Get-LMDeviceDatasourceInstanceAlertRecipients { [CmdletBinding()] Param ( [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] @@ -12,10 +47,12 @@ Function Get-LMDeviceDatasourceInstanceAlertRecipients { [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Alias('DeviceId')] [Int]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Alias('DeviceName')] [String]$Name, [Parameter(Mandatory)] diff --git a/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 b/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 index 306e7cf..e89d2dc 100644 --- a/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 @@ -1,3 +1,43 @@ +<# +.SYNOPSIS +Retrieves the alert settings for a specific LogicMonitor device datasource instance. + +.DESCRIPTION +The Get-LMDeviceDatasourceInstanceAlertSetting function retrieves the alert settings for a specific LogicMonitor device datasource instance. It requires the device name or ID, datasource name or ID, and instance name as input parameters. Optionally, you can also provide a filter to narrow down the results. The function returns an array of alert settings for the specified instance. + +.PARAMETER DatasourceName +Specifies the name of the datasource. This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter set. + +.PARAMETER DatasourceId +Specifies the ID of the datasource. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter set. + +.PARAMETER Id +Specifies the ID of the device. This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter set. This parameter can also be specified using the 'DeviceId' alias. + +.PARAMETER Name +Specifies the name of the device. This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter set. This parameter can also be specified using the 'DeviceName' alias. + +.PARAMETER InstanceName +Specifies the name of the instance for which to retrieve the alert settings. This parameter is mandatory. + +.PARAMETER Filter +Specifies a filter to narrow down the results. This parameter is optional. + +.PARAMETER BatchSize +Specifies the number of results to retrieve per batch. The default value is 1000. This parameter is optional. + +.EXAMPLE +Get-LMDeviceDatasourceInstanceAlertSetting -Name "MyDevice" -DatasourceName "MyDatasource" -InstanceName "MyInstance" +Retrieves the alert settings for the instance named "MyInstance" of the datasource "MyDatasource" on the device named "MyDevice". + +.EXAMPLE +Get-LMDeviceDatasourceInstanceAlertSetting -Id 123 -DatasourceId 456 -InstanceName "MyInstance" -Filter "Property -eq 'value'" +Retrieves the alert settings for the instance named "MyInstance" of the datasource with ID 456 on the device with ID 123, applying the specified filter. + +.NOTES +This function requires a valid LogicMonitor API authentication. Make sure you are logged in before running any commands by using the Connect-LMAccount function. +#> + Function Get-LMDeviceDatasourceInstanceAlertSetting { [CmdletBinding()] @@ -12,10 +52,12 @@ Function Get-LMDeviceDatasourceInstanceAlertSetting { [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Alias('DeviceId')] [Int]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Alias('DeviceName')] [String]$Name, [Parameter(Mandatory)] diff --git a/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 b/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 index d6a422c..34ef9fb 100644 --- a/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceGroup.ps1 @@ -1,3 +1,45 @@ +<# +.SYNOPSIS +Retrieves the instance groups associated with a LogicMonitor device datasource. + +.DESCRIPTION +The Get-LMDeviceDatasourceInstanceGroup function retrieves the instance groups associated with a LogicMonitor device datasource. It requires valid API credentials and a logged-in session. + +.PARAMETER DatasourceName +Specifies the name of the datasource. This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. + +.PARAMETER DatasourceId +Specifies the ID of the datasource. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. + +.PARAMETER Id +Specifies the ID of the device. This parameter is mandatory when using the 'Id-dsId', 'Id-dsName', or 'Id-HdsId' parameter sets. This parameter is also aliased as 'DeviceId'. + +.PARAMETER Name +Specifies the name of the device. This parameter is mandatory when using the 'Name-dsName', 'Name-dsId', or 'Name-HdsId' parameter sets. This parameter is also aliased as 'DeviceName'. + +.PARAMETER HdsId +Specifies the ID of the device datasource. This parameter is mandatory when using the 'Id-HdsId' or 'Name-HdsId' parameter sets. + +.PARAMETER Filter +Specifies an optional filter to apply to the results. + +.PARAMETER BatchSize +Specifies the number of results to retrieve per batch. The default value is 1000. + +.EXAMPLE +Get-LMDeviceDatasourceInstanceGroup -DatasourceName "CPU" -Name "Server01" +Retrieves the instance groups associated with the "CPU" datasource on the device named "Server01". + +.EXAMPLE +Get-LMDeviceDatasourceInstanceGroup -DatasourceId 123 -Id 456 +Retrieves the instance groups associated with the datasource with ID 123 on the device with ID 456. + +#> + +Function Get-LMDeviceDatasourceInstanceGroup { + ... +} + Function Get-LMDeviceDatasourceInstanceGroup { [CmdletBinding()] @@ -13,11 +55,13 @@ Function Get-LMDeviceDatasourceInstanceGroup { [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] [Parameter(Mandatory, ParameterSetName = 'Id-HdsId')] + [Alias('DeviceId')] [Int]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] [Parameter(Mandatory, ParameterSetName = 'Name-HdsId')] + [Alias('DeviceName')] [String]$Name, [Parameter(Mandatory, ParameterSetName = 'Id-HdsId')] diff --git a/Public/New-LMDeviceDatasourceInstance.ps1 b/Public/New-LMDeviceDatasourceInstance.ps1 index 7534ff5..77500d7 100644 --- a/Public/New-LMDeviceDatasourceInstance.ps1 +++ b/Public/New-LMDeviceDatasourceInstance.ps1 @@ -81,10 +81,12 @@ Function New-LMDeviceDatasourceInstance { [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Alias('DeviceId')] [Int]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Alias('DeviceName')] [String]$Name ) diff --git a/Public/New-LMDeviceDatasourceInstanceGroup.ps1 b/Public/New-LMDeviceDatasourceInstanceGroup.ps1 index 3c53dce..3dc4371 100644 --- a/Public/New-LMDeviceDatasourceInstanceGroup.ps1 +++ b/Public/New-LMDeviceDatasourceInstanceGroup.ps1 @@ -51,10 +51,12 @@ Function New-LMDeviceDatasourceInstanceGroup { [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Alias('DeviceId')] [Int]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Alias('DeviceName')] [String]$Name ) diff --git a/Public/Remove-LMDeviceDatasourceInstance.ps1 b/Public/Remove-LMDeviceDatasourceInstance.ps1 index 9cac3b6..fddec8c 100644 --- a/Public/Remove-LMDeviceDatasourceInstance.ps1 +++ b/Public/Remove-LMDeviceDatasourceInstance.ps1 @@ -11,21 +11,21 @@ Specifies the name of the datasource. This parameter is mandatory when using the .PARAMETER DatasourceId Specifies the ID of the datasource. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. -.PARAMETER DeviceId +.PARAMETER Id Specifies the ID of the device. This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. -.PARAMETER DeviceName +.PARAMETER Name Specifies the name of the device. This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. .PARAMETER WildValue Specifies the wildcard value associated with the datasource instance. .EXAMPLE -Remove-LMDeviceDatasourceInstance -DeviceName "MyDevice" -DatasourceName "MyDatasource" -WildValue "12345" +Remove-LMDeviceDatasourceInstance -Name "MyDevice" -DatasourceName "MyDatasource" -WildValue "12345" Removes the device datasource instance with the specified device name, datasource name, and wildcard value. .EXAMPLE -Remove-LMDeviceDatasourceInstance -DeviceId 123 -DatasourceId 456 -WildValue "67890" +Remove-LMDeviceDatasourceInstance -Id 123 -DatasourceId 456 -WildValue "67890" Removes the device datasource instance with the specified device ID, datasource ID, and wildcard value. .INPUTS @@ -56,7 +56,11 @@ Function Remove-LMDeviceDatasourceInstance { [String]$DeviceName, [Parameter(ValueFromPipelineByPropertyName)] - [String]$WildValue = $null + [String]$WildValue, + + [Parameter(ValueFromPipelineByPropertyName)] + [Alias("Id")] + [Int]$InstanceId ) @@ -84,10 +88,14 @@ Function Remove-LMDeviceDatasourceInstance { } #Lookup Wildcard Id - $InstanceId = (Get-LMDeviceDataSourceInstance -DeviceId $DeviceId -DatasourceId $DatasourceId | Where-Object { $_.wildValue -eq $WildValue } | Select-Object -First 1).Id - If (!$InstanceId) { - Write-Error "Unable to find assocaited datasource instance with wildcard value: $WildValue, please check spelling and try again. Datasource must have an applicable appliesTo associating the datasource to the device" - return + If(!$InstanceId -and $WildValue) { + $InstanceId = (Get-LMDeviceDataSourceInstance -Id $DeviceId -DatasourceId $DatasourceId | Where-Object { $_.wildValue -eq $WildValue }).Id + If (Test-LookupResult -Result $LookupResult -LookupString $InstanceId) { + return + } + } + Else{ + Write-Error "Please provide a valid instance ID or wildvalue to remove a device datasource instance." } #Build header and uri @@ -97,10 +105,10 @@ Function Remove-LMDeviceDatasourceInstance { $Message = "DeviceDisplayName: $($PSItem.deviceDisplayName) | DatasourceName: $($PSItem.name) | WildValue: $($PSItem.wildValue)" } Elseif ($DatasourceName -and $DeviceName) { - $Message = "DeviceName: $DeviceName | DatasourceName: $DatasourceName | WildValue: $WildValue" + $Message = "Name: $DeviceName | DatasourceName: $DatasourceName | WildValue: $WildValue" } Else { - $Message = "DeviceId: $DeviceId | DatasourceId: $DatasourceId | WildValue: $WildValue" + $Message = "Id: $DeviceId | DatasourceId: $DatasourceId | WildValue: $WildValue" } Try { diff --git a/Public/Remove-LMDeviceDatasourceInstanceGroup.ps1 b/Public/Remove-LMDeviceDatasourceInstanceGroup.ps1 new file mode 100644 index 0000000..e930c2c --- /dev/null +++ b/Public/Remove-LMDeviceDatasourceInstanceGroup.ps1 @@ -0,0 +1,128 @@ +<# +.SYNOPSIS +Removes a LogicMonitor device datasource instance group. + +.DESCRIPTION +The Remove-LMDeviceDatasourceInstanceGroup function removes a LogicMonitor device datasource instance group based on the provided parameters. It requires valid API credentials and a logged-in session. + +.PARAMETER DatasourceName +Specifies the name of the datasource associated with the instance group. This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. + +.PARAMETER DatasourceId +Specifies the ID of the datasource associated with the instance group. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. + +.PARAMETER Id +Specifies the ID of the device associated with the instance group. This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. This parameter can also be specified using the 'DeviceId' alias. + +.PARAMETER Name +Specifies the name of the device associated with the instance group. This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. This parameter can also be specified using the 'DeviceName' alias. + +.PARAMETER InstanceGroupName +Specifies the name of the instance group to be removed. This parameter is mandatory. + +.EXAMPLE +Remove-LMDeviceDatasourceInstanceGroup -DatasourceName "CPU" -Name "Server01" -InstanceGroupName "Group1" +Removes the instance group named "Group1" associated with the "CPU" datasource on the device named "Server01". + +.EXAMPLE +Remove-LMDeviceDatasourceInstanceGroup -DatasourceId 123 -Id 456 -InstanceGroupName "Group2" +Removes the instance group named "Group2" associated with the datasource ID 123 on the device ID 456. + +.INPUTS +None. You cannot pipe objects to this function. +#> + +Function Remove-LMDeviceDatasourceInstanceGroup { + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] + Param ( + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] + [String]$DatasourceName, + + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Int]$DatasourceId, + + [Parameter(Mandatory, ParameterSetName = 'Id-dsId')] + [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] + [Alias('DeviceId')] + [Int]$Id, + + [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] + [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] + [Alias('DeviceName')] + [String]$Name, + + [Parameter(Mandatory)] + [String]$InstanceGroupName + ) + #Check if we are logged in and have valid api creds + If ($Script:LMAuth.Valid) { + + #Lookup Device Id + If ($Name) { + $LookupResult = (Get-LMDevice -Name $Name).Id + If (Test-LookupResult -Result $LookupResult -LookupString $Name) { + return + } + $Id = $LookupResult + } + + #Lookup DatasourceId + If ($DatasourceName -or $DatasourceId) { + $LookupResult = (Get-LMDeviceDataSourceList -Id $Id | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id + If (Test-LookupResult -Result $LookupResult -LookupString $DatasourceName) { + return + } + $HdsId = $LookupResult + } + + #Lookup InstanceGroupId + $LookupResult = (Get-LMDeviceDatasourceInstanceGroup -Id $Id -HdsId $HdsId -Filter "name -eq '$InstanceGroupName'").Id + If (Test-LookupResult -Result $LookupResult -LookupString $InstanceGroupName) { + return + } + $InstanceGroupId = $LookupResult + + #Build header and uri + $ResourcePath = "/device/devices/$Id/devicedatasources/$HdsId/groups/$InstanceGroupId" + + If ($PSItem) { + $Message = "DeviceDisplayName: $($PSItem.deviceDisplayName) | DatasourceName: $($PSItem.name) | InstanceGroupName: $($PSItem.InstanceGroupName)" + } + Elseif ($DatasourceName -and $DeviceName) { + $Message = "DeviceName: $DeviceName | DatasourceName: $DatasourceName | InstanceGroupName: $InstanceGroupName" + } + Else { + $Message = "DeviceId: $DeviceId | DatasourceId: $DatasourceId | InstanceGroupName: $InstanceGroupName" + } + + Try { + If ($PSCmdlet.ShouldProcess($Message, "Remove Device Datasource Instance Group")) { + $Headers = New-LMHeader -Auth $Script:LMAuth -Method "DELETE" -ResourcePath $ResourcePath + $Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + + Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation + + #Issue request + $Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] + + $Result = [PSCustomObject]@{ + InstanceId = $InstanceId + Message = "Successfully removed ($Message)" + } + + Return $Result + } + } + Catch [Exception] { + $Proceed = Resolve-LMException -LMException $PSItem + If (!$Proceed) { + Return + } + } + } + Else { + Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." + } +} diff --git a/Public/Set-LMDeviceDatasourceInstance.ps1 b/Public/Set-LMDeviceDatasourceInstance.ps1 index 34feecc..ca858e5 100644 --- a/Public/Set-LMDeviceDatasourceInstance.ps1 +++ b/Public/Set-LMDeviceDatasourceInstance.ps1 @@ -1,3 +1,61 @@ +<# +.SYNOPSIS +Sets the properties of a LogicMonitor device datasource instance. + +.DESCRIPTION +The Set-LMDeviceDatasourceInstance function is used to set the properties of a LogicMonitor device datasource instance. It allows you to update the display name, wild values, description, custom properties, monitoring and alerting settings, and instance group ID of the specified instance. + +.PARAMETER DisplayName +Specifies the new display name for the instance. + +.PARAMETER WildValue +Specifies the first wild value for the instance. + +.PARAMETER WildValue2 +Specifies the second wild value for the instance. + +.PARAMETER Description +Specifies the description for the instance. + +.PARAMETER Properties +Specifies a hashtable of custom properties for the instance. + +.PARAMETER StopMonitoring +Specifies whether to stop monitoring the instance. This parameter accepts $true or $false. + +.PARAMETER DisableAlerting +Specifies whether to disable alerting for the instance. This parameter accepts $true or $false. + +.PARAMETER InstanceGroupId +Specifies the ID of the instance group to which the instance belongs. + +.PARAMETER InstanceId +Specifies the ID of the instance to update. This parameter is mandatory and can be provided via pipeline. + +.PARAMETER DatasourceName +Specifies the name of the datasource associated with the instance. This parameter is mandatory when using the 'Name-dsName' parameter set. + +.PARAMETER DatasourceId +Specifies the ID of the datasource associated with the instance. This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter set. + +.PARAMETER Id +Specifies the ID of the device associated with the instance. This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter set. This parameter can also be specified using the 'DeviceId' alias. + +.PARAMETER Name +Specifies the name of the device associated with the instance. This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter set. This parameter can also be specified using the 'DeviceName' alias. + +.EXAMPLE +Set-LMDeviceDatasourceInstance -InstanceId 12345 -DisplayName "New Instance Name" -Description "Updated instance description" + +This example sets the display name and description of the instance with ID 12345. + +.EXAMPLE +Get-LMDevice -Name "MyDevice" | Set-LMDeviceDatasourceInstance -DatasourceName "MyDatasource" -DisplayName "New Instance Name" + +This example retrieves the device with the name "MyDevice" and sets the display name of the instance associated with the datasource "MyDatasource". + +#> + Function Set-LMDeviceDatasourceInstance { [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'None')] @@ -19,7 +77,6 @@ Function Set-LMDeviceDatasourceInstance { [String]$InstanceGroupId, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] - [Alias("Id")] [String]$InstanceId, [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] @@ -32,11 +89,13 @@ Function Set-LMDeviceDatasourceInstance { [Parameter(Mandatory, ParameterSetName = 'Id-dsId', ValueFromPipelineByPropertyName)] [Parameter(Mandatory, ParameterSetName = 'Id-dsName')] - [String]$DeviceId, + [Alias('DeviceId')] + [String]$Id, [Parameter(Mandatory, ParameterSetName = 'Name-dsName')] [Parameter(Mandatory, ParameterSetName = 'Name-dsId')] - [String]$DeviceName + [Alias('DeviceName')] + [String]$Name ) @@ -46,17 +105,17 @@ Function Set-LMDeviceDatasourceInstance { If ($Script:LMAuth.Valid) { #Lookup Device Id - If ($DeviceName) { - $LookupResult = (Get-LMDevice -Name $DeviceName).Id - If (Test-LookupResult -Result $LookupResult -LookupString $DeviceName) { + If ($Name) { + $LookupResult = (Get-LMDevice -Name $Name).Id + If (Test-LookupResult -Result $LookupResult -LookupString $Name) { return } - $DeviceId = $LookupResult + $Id = $LookupResult } #Lookup DatasourceId If ($DatasourceName -or $DatasourceId) { - $LookupResult = (Get-LMDeviceDataSourceList -Id $DeviceId | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id + $LookupResult = (Get-LMDeviceDataSourceList -Id $Id | Where-Object { $_.dataSourceName -eq $DatasourceName -or $_.dataSourceId -eq $DatasourceId }).Id If (Test-LookupResult -Result $LookupResult -LookupString $DatasourceName) { return } @@ -72,16 +131,16 @@ Function Set-LMDeviceDatasourceInstance { } #Build header and uri - $ResourcePath = "/device/devices/$DeviceId/devicedatasources/$HdsId/instances/$instanceId" + $ResourcePath = "/device/devices/$Id/devicedatasources/$HdsId/instances/$instanceId" If ($PSItem) { $Message = "deviceDisplayName: $($PSItem.deviceDisplayName) | instanceId: $($PSItem.id) | instanceName: $($PSItem.name)" } - Elseif ($DeviceName) { - $Message = "deviceDisplayName: $DeviceName | instanceId: $InstanceId" + Elseif ($Name) { + $Message = "deviceDisplayName: $Name | instanceId: $InstanceId" } Else { - $Message = "instanceId: $InstanceId | deviceId: $DeviceId" + $Message = "instanceId: $InstanceId | Id: $Id" } Try { diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 1492bb7..4706d35 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,4 +1,17 @@ # Previous module release notes +## 6.0 +### New Cmdlets: + - **Get-LMDeviceInstanceData**: This cmdlet retrieves data for LogicMonitor device instances based on the specified parameters. The cmdlet can only retrieve data within the last 24 hours. You can use `Get-LMDeviceInstanceList` to quickly get a list of instances for a particular device. + - **New-LMAlertEscalation**: This cmdlet invokes an escalation for a LogicMonitor alert. It takes a *-Ids* parameter which is an array of alert ids to escalate. + - **Get-LMAccessGroup**: This cmdlet will retrieve data for specified LogicMonitor access groups. You can retrieve all access groups or limit the results using *-Id*, *-Name* or *-Filter* parameters. + + **Note**: Access Groups are not available in all portals and needs to be enabled before any access group commands can be utilized. + + +### Updated Cmdlets: + - **Set-LMDeviceDatasourceInstanceAlertSetting**: AlertForNoData, AlertClearTransitionInterval and AlertTransitionInterval parameters are now mandatory as a result of endpoint changes for LM APIv3. These values can now be set at instance and group level overrides and as a result must be specified when modifying alert thresholds. + - **Set-LMDeviceGroupDatasourceAlertSetting**: AlertForNoData, AlertClearTransitionInterval and AlertTransitionInterval parameters are now mandatory as a result of endpoint changes for LM APIv3. These values can now be set at instance and group level overrides and as a result must be specified when modifying alert thresholds. + ## 5.1.3 ### Updated Cmdlets: - **New-LMRole**: From 0c7790bd7a70a608018ea4e6d503acc7294de822 Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Wed, 3 Jul 2024 15:54:34 -0400 Subject: [PATCH 5/6] Update readme --- Public/Get-LMDeviceData.ps1 | 2 ++ ...DeviceDatasourceInstanceAlertRecipients.ps1 | 4 ++++ ...-LMDeviceDatasourceInstanceAlertSetting.ps1 | 4 ++++ ...-LMDeviceDatasourceInstanceAlertSetting.ps1 | 3 +++ README.md | 18 +++++++++++++----- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Public/Get-LMDeviceData.ps1 b/Public/Get-LMDeviceData.ps1 index d025eef..dbb04a1 100644 --- a/Public/Get-LMDeviceData.ps1 +++ b/Public/Get-LMDeviceData.ps1 @@ -84,6 +84,8 @@ Function Get-LMDeviceData { #Lookup InstanceId If ($InstanceName) { + #Replace brakets in instance name + $InstanceName = $InstanceName -replace "[\[\]]", "?" $LookupResult = (Get-LMDeviceDatasourceInstance -DeviceId $DeviceId -DatasourceId $DatasourceId | Where-Object { $_.displayName -eq $InstanceName -or $_.name -like "*$InstanceName" -or $_.name -eq "$InstanceName" }).Id If (Test-LookupResult -Result $LookupResult -LookupString $InstanceName) { diff --git a/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 b/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 index d7059c2..e75ee93 100644 --- a/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceAlertRecipients.ps1 @@ -81,6 +81,10 @@ Function Get-LMDeviceDatasourceInstanceAlertRecipients { } $HdsId = $LookupResult } + + #Replace brakets in instance name + $InstanceName = $InstanceName -replace "[\[\]]", "?" + #Lookup HdsiId If ($DatasourceName) { $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName"}).Id diff --git a/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 b/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 index e89d2dc..51b5a95 100644 --- a/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 +++ b/Public/Get-LMDeviceDatasourceInstanceAlertSetting.ps1 @@ -89,6 +89,10 @@ Function Get-LMDeviceDatasourceInstanceAlertSetting { } $HdsId = $LookupResult } + + #Replace brakets in instance name + $InstanceName = $InstanceName -replace "[\[\]]", "?" + #Lookup HdsiId If ($DatasourceName) { $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName" }).Id diff --git a/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 b/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 index 6aa5ab0..72639f3 100644 --- a/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 +++ b/Public/Set-LMDeviceDatasourceInstanceAlertSetting.ps1 @@ -70,6 +70,9 @@ Function Set-LMDeviceDatasourceInstanceAlertSetting { $HdsId = $LookupResult } + #Replace brakets in instance name + $InstanceName = $InstanceName -replace "[\[\]]", "?" + #Lookup HdsiId If ($DatasourceName) { $LookupResult = (Get-LMDeviceDatasourceInstance -DatasourceName $DatasourceName -DeviceId $Id | Where-Object { $_.name -like "*$InstanceName" }).Id diff --git a/README.md b/README.md index 2f98da6..96109b2 100644 --- a/README.md +++ b/README.md @@ -409,18 +409,26 @@ This change aims to enhance visibility within the community and to foster a more We appreciate your continued support and enthusiasm for the Logic.Monitor PowerShell module. Your contributions and feedback are vital to the success of this project, and we look forward to seeing how the module evolves with your participation. -## 6.0 +## 6.1 ### New Cmdlets: - - **Get-LMDeviceInstanceData**: This cmdlet retrieves data for LogicMonitor device instances based on the specified parameters. The cmdlet can only retrieve data within the last 24 hours. You can use `Get-LMDeviceInstanceList` to quickly get a list of instances for a particular device. - - **New-LMAlertEscalation**: This cmdlet invokes an escalation for a LogicMonitor alert. It takes a *-Ids* parameter which is an array of alert ids to escalate. - **Get-LMAccessGroup**: This cmdlet will retrieve data for specified LogicMonitor access groups. You can retrieve all access groups or limit the results using *-Id*, *-Name* or *-Filter* parameters. + - **New-LMAccessGroup**: This cmdlet creates a new LogicMonitor access group. + - **Set-LMAccessGroup**: This cmdlet updates an existing LogicMonitor access group. + - **Remove-LMAccessGroup**: This cmdlet removes a new LogicMonitor access group. + - **Get-LMDeviceDatasourceInstanceAlertRecipients**: Retrieves the alert recipients for a specific data point in a LogicMonitor device datasource instance. + - **Remove-LMDeviceDatasourceInstanceGroup**: Removes a LogicMonitor device datasource instance group. + - **Set-LMDeviceDatasourceInstance**: Updates a LogicMonitor device datasource instance. **Note**: Access Groups are not available in all portals and needs to be enabled before any access group commands can be utilized. ### Updated Cmdlets: - - **Set-LMDeviceDatasourceInstanceAlertSetting**: AlertForNoData, AlertClearTransitionInterval and AlertTransitionInterval parameters are now mandatory as a result of endpoint changes for LM APIv3. These values can now be set at instance and group level overrides and as a result must be specified when modifying alert thresholds. - - **Set-LMDeviceGroupDatasourceAlertSetting**: AlertForNoData, AlertClearTransitionInterval and AlertTransitionInterval parameters are now mandatory as a result of endpoint changes for LM APIv3. These values can now be set at instance and group level overrides and as a result must be specified when modifying alert thresholds. + - **Get-LMDeviceDatasourceList**: Added aliases *-DeviceId* and *-DeviceName* to the *-Id* and *-Name* parameters to make them inline with other cmdlets. + - **Get-LMDeviceDatasourceInstance**: Added aliases *-DeviceId* and *-DeviceName* to the *-Id* and *-Name* parameters to make them inline with other cmdlets. + - **Get-LMDeviceDatasourceInstanceAlertSetting**: Added aliases *-DeviceId* and *-DeviceName* to the *-Id* and *-Name* parameters to make them inline with other cmdlets. Also fixed bug causing an issue when trying to retrieve instances with special characters in the name. + - **Get-LMDeviceDatasourceInstanceGroup**: Added aliases *-DeviceId* and *-DeviceName* to the *-Id* and *-Name* parameters to make them inline with other cmdlets. + - **Remove-LMDeviceDatasourceInstance**: Fixed bug that would prevent a datasource instance from being delete due to missing instance id. + [Previous Release Notes](RELEASENOTES.md) From d9ac2296f10df914b81cf1f62cb269f3d808d7e3 Mon Sep 17 00:00:00 2001 From: Steve Villardi <42367049+stevevillardi@users.noreply.github.com> Date: Fri, 5 Jul 2024 09:41:14 -0400 Subject: [PATCH 6/6] update docs --- Documentation/Disconnect-LMAccount.md | 5 +- Documentation/Get-LMAccessGroup.md | 2 +- Documentation/Get-LMAccountStatus.md | 5 +- .../Get-LMDeviceDatasourceInstance.md | 100 +++++---- ...DeviceDatasourceInstanceAlertRecipients.md | 70 ++++--- ...-LMDeviceDatasourceInstanceAlertSetting.md | 100 +++++---- .../Get-LMDeviceDatasourceInstanceGroup.md | 4 +- Documentation/Get-LMDeviceDatasourceList.md | 4 +- Documentation/New-LMAccessGroup.md | 36 ++-- .../New-LMDeviceDatasourceInstance.md | 4 +- .../New-LMDeviceDatasourceInstanceGroup.md | 4 +- Documentation/Remove-LMAccessGroup.md | 61 +++--- .../Remove-LMDeviceDatasourceInstance.md | 33 ++- .../Remove-LMDeviceDatasourceInstanceGroup.md | 197 ++++++++++++++++++ Documentation/Set-LMAccessGroup.md | 59 +++--- .../Set-LMDeviceDatasourceInstance.md | 191 +++++++++-------- README.md | 1 - 17 files changed, 586 insertions(+), 290 deletions(-) create mode 100644 Documentation/Remove-LMDeviceDatasourceInstanceGroup.md diff --git a/Documentation/Disconnect-LMAccount.md b/Documentation/Disconnect-LMAccount.md index cdec45e..8d14fa0 100644 --- a/Documentation/Disconnect-LMAccount.md +++ b/Documentation/Disconnect-LMAccount.md @@ -13,7 +13,7 @@ Disconnect from a previously connected LM portal ## SYNTAX ``` -Disconnect-LMAccount +Disconnect-LMAccount [] ``` ## DESCRIPTION @@ -29,6 +29,9 @@ Disconnect-LMAccount ## PARAMETERS +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### None. You cannot pipe objects to this command. diff --git a/Documentation/Get-LMAccessGroup.md b/Documentation/Get-LMAccessGroup.md index 4bf9d3e..fdafe00 100644 --- a/Documentation/Get-LMAccessGroup.md +++ b/Documentation/Get-LMAccessGroup.md @@ -55,7 +55,7 @@ Retrieves the access group with the specified name. ### EXAMPLE 3 ``` -Get-LMAccessGroup -Filter @{ Property = "Value" } +Get-LMAccessGroup -Filter "tenantId -eq 'Value'" Retrieves access groups based on the specified filter criteria. ``` diff --git a/Documentation/Get-LMAccountStatus.md b/Documentation/Get-LMAccountStatus.md index 8947090..06839ec 100644 --- a/Documentation/Get-LMAccountStatus.md +++ b/Documentation/Get-LMAccountStatus.md @@ -13,7 +13,7 @@ Retrieves the status of the LogicMonitor account. ## SYNTAX ``` -Get-LMAccountStatus +Get-LMAccountStatus [] ``` ## DESCRIPTION @@ -31,6 +31,9 @@ This example demonstrates how to use the Get-LMAccountStatus function to retriev ## PARAMETERS +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ## OUTPUTS diff --git a/Documentation/Get-LMDeviceDatasourceInstance.md b/Documentation/Get-LMDeviceDatasourceInstance.md index c6c537c..fa5bb44 100644 --- a/Documentation/Get-LMDeviceDatasourceInstance.md +++ b/Documentation/Get-LMDeviceDatasourceInstance.md @@ -8,57 +8,64 @@ schema: 2.0.0 # Get-LMDeviceDatasourceInstance ## SYNOPSIS -{{ Fill in the Synopsis }} +Retrieves instances of a LogicMonitor device datasource. ## SYNTAX ### Name-dsName ``` -Get-LMDeviceDatasourceInstance -DatasourceName -DeviceName [-Filter ] - [-BatchSize ] [-ProgressAction ] [] +Get-LMDeviceDatasourceInstance -DatasourceName -Name [-Filter ] [-BatchSize ] + [-ProgressAction ] [] ``` ### Id-dsName ``` -Get-LMDeviceDatasourceInstance -DatasourceName -DeviceId [-Filter ] - [-BatchSize ] [-ProgressAction ] [] +Get-LMDeviceDatasourceInstance -DatasourceName -Id [-Filter ] [-BatchSize ] + [-ProgressAction ] [] ``` ### Name-dsId ``` -Get-LMDeviceDatasourceInstance -DatasourceId -DeviceName [-Filter ] - [-BatchSize ] [-ProgressAction ] [] +Get-LMDeviceDatasourceInstance -DatasourceId -Name [-Filter ] [-BatchSize ] + [-ProgressAction ] [] ``` ### Id-dsId ``` -Get-LMDeviceDatasourceInstance -DatasourceId -DeviceId [-Filter ] [-BatchSize ] +Get-LMDeviceDatasourceInstance -DatasourceId -Id [-Filter ] [-BatchSize ] [-ProgressAction ] [] ``` ## DESCRIPTION -{{ Fill in the Description }} +The Get-LMDeviceDatasourceInstance function retrieves instances of a LogicMonitor device datasource based on the specified parameters. +It requires a valid API authentication and authorization. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +Get-LMDeviceDatasourceInstance -DatasourceName "CPU" -Name "Server01" -BatchSize 500 +Retrieves instances of the "CPU" datasource for the device named "Server01" with a batch size of 500. ``` -{{ Add example description here }} +### EXAMPLE 2 +``` +Get-LMDeviceDatasourceInstance -DatasourceId 1234 -Id 5678 +Retrieves instances of the datasource with ID 1234 for the device with ID 5678. +``` ## PARAMETERS -### -BatchSize -{{ Fill BatchSize Description }} +### -DatasourceName +Specifies the name of the datasource. +This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. ```yaml -Type: Int32 -Parameter Sets: (All) +Type: String +Parameter Sets: Name-dsName, Id-dsName Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False @@ -66,7 +73,8 @@ Accept wildcard characters: False ``` ### -DatasourceId -{{ Fill DatasourceId Description }} +Specifies the ID of the datasource. +This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. ```yaml Type: Int32 @@ -75,33 +83,37 @@ Aliases: Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -DatasourceName -{{ Fill DatasourceName Description }} +### -Id +Specifies the ID of the device. +This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. +It can also be specified using the 'DeviceId' alias. ```yaml -Type: String -Parameter Sets: Name-dsName, Id-dsName -Aliases: +Type: Int32 +Parameter Sets: Id-dsName, Id-dsId +Aliases: DeviceId Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -DeviceId -{{ Fill DeviceId Description }} +### -Name +Specifies the name of the device. +This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. +It can also be specified using the 'DeviceName' alias. ```yaml -Type: Int32 -Parameter Sets: Id-dsName, Id-dsId -Aliases: Id +Type: String +Parameter Sets: Name-dsName, Name-dsId +Aliases: DeviceName Required: True Position: Named @@ -110,32 +122,34 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -DeviceName -{{ Fill DeviceName Description }} +### -Filter +Specifies additional filters to apply to the instances. +This parameter accepts an object representing the filter criteria. ```yaml -Type: String -Parameter Sets: Name-dsName, Name-dsId -Aliases: Name +Type: Object +Parameter Sets: (All) +Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Filter -{{ Fill Filter Description }} +### -BatchSize +Specifies the number of instances to retrieve per batch. +The default value is 1000. ```yaml -Type: Object +Type: Int32 Parameter Sets: (All) Aliases: Required: False Position: Named -Default value: None +Default value: 1000 Accept pipeline input: False Accept wildcard characters: False ``` @@ -160,10 +174,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### None ## OUTPUTS -### System.Object ## NOTES +This function requires a valid API authentication and authorization. +Use Connect-LMAccount to log in before running any commands. ## RELATED LINKS diff --git a/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md b/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md index 8e5a5b2..84ca7f0 100644 --- a/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md +++ b/Documentation/Get-LMDeviceDatasourceInstanceAlertRecipients.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Get-LMDeviceDatasourceInstanceAlertRecipients ## SYNOPSIS -{{ Fill in the Synopsis }} +Retrieves the alert recipients for a specific data point in a LogicMonitor device datasource instance. ## SYNTAX @@ -37,25 +37,34 @@ Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceId -Id ``` ## DESCRIPTION -{{ Fill in the Description }} +The Get-LMDeviceDatasourceInstanceAlertRecipients function retrieves the alert recipients for a specific data point in a LogicMonitor device datasource instance. +It requires valid API credentials and a logged-in session. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceName "Ping-" -Name "Server01" -InstanceName "Instance01" -DataPointName "PingLossPercent" +``` + +Retrieves the alert recipients for the "PingLossPercent" data point in the "CPU" datasource instance of the "Server01" device. + +### EXAMPLE 2 +``` +Get-LMDeviceDatasourceInstanceAlertRecipients -DatasourceId 123 -Id 456 -InstanceName "Instance01" -DataPointName "PingLossPercent" ``` -{{ Add example description here }} +Retrieves the alert recipients for the "PingLossPercent" data point in the datasource instance with ID 123 of the device with ID 456. ## PARAMETERS -### -DataPointName -{{ Fill DataPointName Description }} +### -DatasourceName +Specifies the name of the datasource. +This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: Name-dsName, Id-dsName Aliases: Required: True @@ -66,7 +75,8 @@ Accept wildcard characters: False ``` ### -DatasourceId -{{ Fill DatasourceId Description }} +Specifies the ID of the datasource. +This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. ```yaml Type: Int32 @@ -75,33 +85,37 @@ Aliases: Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -DatasourceName -{{ Fill DatasourceName Description }} +### -Id +Specifies the ID of the device. +This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. +It can also be specified using the 'DeviceId' alias. ```yaml -Type: String -Parameter Sets: Name-dsName, Id-dsName -Aliases: +Type: Int32 +Parameter Sets: Id-dsName, Id-dsId +Aliases: DeviceId Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -Id -{{ Fill Id Description }} +### -Name +Specifies the name of the device. +This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. +It can also be specified using the 'DeviceName' alias. ```yaml -Type: Int32 -Parameter Sets: Id-dsName, Id-dsId -Aliases: +Type: String +Parameter Sets: Name-dsName, Name-dsId +Aliases: DeviceName Required: True Position: Named @@ -111,7 +125,8 @@ Accept wildcard characters: False ``` ### -InstanceName -{{ Fill InstanceName Description }} +Specifies the name of the datasource instance. +This parameter is mandatory. ```yaml Type: String @@ -125,12 +140,13 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Name -{{ Fill Name Description }} +### -DataPointName +Specifies the name of the data point. +This parameter is mandatory. ```yaml Type: String -Parameter Sets: Name-dsName, Name-dsId +Parameter Sets: (All) Aliases: Required: True @@ -160,10 +176,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### None ## OUTPUTS -### System.Object ## NOTES ## RELATED LINKS diff --git a/Documentation/Get-LMDeviceDatasourceInstanceAlertSetting.md b/Documentation/Get-LMDeviceDatasourceInstanceAlertSetting.md index 289cd77..fe9baa1 100644 --- a/Documentation/Get-LMDeviceDatasourceInstanceAlertSetting.md +++ b/Documentation/Get-LMDeviceDatasourceInstanceAlertSetting.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Get-LMDeviceDatasourceInstanceAlertSetting ## SYNOPSIS -{{ Fill in the Synopsis }} +Retrieves the alert settings for a specific LogicMonitor device datasource instance. ## SYNTAX @@ -37,28 +37,37 @@ Get-LMDeviceDatasourceInstanceAlertSetting -DatasourceId -Id -In ``` ## DESCRIPTION -{{ Fill in the Description }} +The Get-LMDeviceDatasourceInstanceAlertSetting function retrieves the alert settings for a specific LogicMonitor device datasource instance. +It requires the device name or ID, datasource name or ID, and instance name as input parameters. +Optionally, you can also provide a filter to narrow down the results. +The function returns an array of alert settings for the specified instance. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +Get-LMDeviceDatasourceInstanceAlertSetting -Name "MyDevice" -DatasourceName "MyDatasource" -InstanceName "MyInstance" +Retrieves the alert settings for the instance named "MyInstance" of the datasource "MyDatasource" on the device named "MyDevice". ``` -{{ Add example description here }} +### EXAMPLE 2 +``` +Get-LMDeviceDatasourceInstanceAlertSetting -Id 123 -DatasourceId 456 -InstanceName "MyInstance" -Filter "Property -eq 'value'" +Retrieves the alert settings for the instance named "MyInstance" of the datasource with ID 456 on the device with ID 123, applying the specified filter. +``` ## PARAMETERS -### -BatchSize -{{ Fill BatchSize Description }} +### -DatasourceName +Specifies the name of the datasource. +This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter set. ```yaml -Type: Int32 -Parameter Sets: (All) +Type: String +Parameter Sets: Name-dsName, Id-dsName Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False @@ -66,7 +75,8 @@ Accept wildcard characters: False ``` ### -DatasourceId -{{ Fill DatasourceId Description }} +Specifies the ID of the datasource. +This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter set. ```yaml Type: Int32 @@ -75,47 +85,52 @@ Aliases: Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -DatasourceName -{{ Fill DatasourceName Description }} +### -Id +Specifies the ID of the device. +This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter set. +This parameter can also be specified using the 'DeviceId' alias. ```yaml -Type: String -Parameter Sets: Name-dsName, Id-dsName -Aliases: +Type: Int32 +Parameter Sets: Id-dsName, Id-dsId +Aliases: DeviceId Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -Filter -{{ Fill Filter Description }} +### -Name +Specifies the name of the device. +This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter set. +This parameter can also be specified using the 'DeviceName' alias. ```yaml -Type: Object -Parameter Sets: (All) -Aliases: +Type: String +Parameter Sets: Name-dsName, Name-dsId +Aliases: DeviceName -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Id -{{ Fill Id Description }} +### -InstanceName +Specifies the name of the instance for which to retrieve the alert settings. +This parameter is mandatory. ```yaml -Type: Int32 -Parameter Sets: Id-dsName, Id-dsId +Type: String +Parameter Sets: (All) Aliases: Required: True @@ -125,32 +140,35 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -InstanceName -{{ Fill InstanceName Description }} +### -Filter +Specifies a filter to narrow down the results. +This parameter is optional. ```yaml -Type: String +Type: Object Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Name -{{ Fill Name Description }} +### -BatchSize +Specifies the number of results to retrieve per batch. +The default value is 1000. +This parameter is optional. ```yaml -Type: String -Parameter Sets: Name-dsName, Name-dsId +Type: Int32 +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named -Default value: None +Default value: 1000 Accept pipeline input: False Accept wildcard characters: False ``` @@ -175,10 +193,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### None ## OUTPUTS -### System.Object ## NOTES +This function requires a valid LogicMonitor API authentication. +Make sure you are logged in before running any commands by using the Connect-LMAccount function. ## RELATED LINKS diff --git a/Documentation/Get-LMDeviceDatasourceInstanceGroup.md b/Documentation/Get-LMDeviceDatasourceInstanceGroup.md index 85941a0..423e8cf 100644 --- a/Documentation/Get-LMDeviceDatasourceInstanceGroup.md +++ b/Documentation/Get-LMDeviceDatasourceInstanceGroup.md @@ -143,7 +143,7 @@ Accept wildcard characters: False ```yaml Type: Int32 Parameter Sets: Id-dsName, Id-dsId, Id-HdsId -Aliases: +Aliases: DeviceId Required: True Position: Named @@ -158,7 +158,7 @@ Accept wildcard characters: False ```yaml Type: String Parameter Sets: Name-dsName, Name-dsId, Name-HdsId -Aliases: +Aliases: DeviceName Required: True Position: Named diff --git a/Documentation/Get-LMDeviceDatasourceList.md b/Documentation/Get-LMDeviceDatasourceList.md index cbaefc8..47ef211 100644 --- a/Documentation/Get-LMDeviceDatasourceList.md +++ b/Documentation/Get-LMDeviceDatasourceList.md @@ -74,7 +74,7 @@ Accept wildcard characters: False ```yaml Type: Int32 Parameter Sets: Id -Aliases: +Aliases: DeviceId Required: True Position: Named @@ -89,7 +89,7 @@ Accept wildcard characters: False ```yaml Type: String Parameter Sets: Name -Aliases: +Aliases: DeviceName Required: False Position: Named diff --git a/Documentation/New-LMAccessGroup.md b/Documentation/New-LMAccessGroup.md index c14941f..df55514 100644 --- a/Documentation/New-LMAccessGroup.md +++ b/Documentation/New-LMAccessGroup.md @@ -8,7 +8,7 @@ schema: 2.0.0 # New-LMAccessGroup ## SYNOPSIS -{{ Fill in the Synopsis }} +Creates a new LogicMonitor access group. ## SYNTAX @@ -18,51 +18,53 @@ New-LMAccessGroup [-Name] [[-Description] ] [[-Tenant] ``` ## DESCRIPTION -{{ Fill in the Description }} +The New-LMAccessGroup function is used to create a new access group in LogicMonitor. +An access group is a collection of users with similar permissions and access rights for managing modules in the LM exchange and my module toolbox. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +New-LMAccessGroup -Name "Group1" -Description "Access group for administrators" -Tenant "12345" ``` -{{ Add example description here }} +This example creates a new access group named "Group1" with the description "Access group for administrators" and assigns it to the tenant with ID "12345". ## PARAMETERS -### -Description -{{ Fill Description Description }} +### -Name +The name of the access group. +This parameter is mandatory. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Name -{{ Fill Name Description }} +### -Description +The description of the access group. ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True -Position: 0 +Required: False +Position: 2 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -Tenant -{{ Fill Tenant Description }} +The ID of the tenant to which the access group belongs. ```yaml Type: String @@ -70,7 +72,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 2 +Position: 3 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -96,10 +98,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### None ## OUTPUTS -### System.Object ## NOTES +For this function to work, you need to be logged in and have valid API credentials. +Use the Connect-LMAccount function to log in before running any commands. ## RELATED LINKS diff --git a/Documentation/New-LMDeviceDatasourceInstance.md b/Documentation/New-LMDeviceDatasourceInstance.md index 54a775b..ad29e0a 100644 --- a/Documentation/New-LMDeviceDatasourceInstance.md +++ b/Documentation/New-LMDeviceDatasourceInstance.md @@ -220,7 +220,7 @@ Mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. ```yaml Type: Int32 Parameter Sets: Id-dsName, Id-dsId -Aliases: +Aliases: DeviceId Required: True Position: Named @@ -236,7 +236,7 @@ Mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. ```yaml Type: String Parameter Sets: Name-dsName, Name-dsId -Aliases: +Aliases: DeviceName Required: True Position: Named diff --git a/Documentation/New-LMDeviceDatasourceInstanceGroup.md b/Documentation/New-LMDeviceDatasourceInstanceGroup.md index 7b5c3fd..78a6976 100644 --- a/Documentation/New-LMDeviceDatasourceInstanceGroup.md +++ b/Documentation/New-LMDeviceDatasourceInstanceGroup.md @@ -126,7 +126,7 @@ This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter se ```yaml Type: Int32 Parameter Sets: Id-dsName, Id-dsId -Aliases: +Aliases: DeviceId Required: True Position: Named @@ -142,7 +142,7 @@ This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' paramete ```yaml Type: String Parameter Sets: Name-dsName, Name-dsId -Aliases: +Aliases: DeviceName Required: True Position: Named diff --git a/Documentation/Remove-LMAccessGroup.md b/Documentation/Remove-LMAccessGroup.md index 34f04d3..9d35577 100644 --- a/Documentation/Remove-LMAccessGroup.md +++ b/Documentation/Remove-LMAccessGroup.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Remove-LMAccessGroup ## SYNOPSIS -{{ Fill in the Synopsis }} +Removes a LogicMonitor access group. ## SYNTAX @@ -24,36 +24,27 @@ Remove-LMAccessGroup -Name [-ProgressAction ] [-WhatI ``` ## DESCRIPTION -{{ Fill in the Description }} +The Remove-LMAccessGroup function removes a LogicMonitor access group based on the specified ID or name. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +Remove-LMAccessGroup -Id 123 +Removes the access group with the ID 123. ``` -{{ Add example description here }} +### EXAMPLE 2 +``` +Remove-LMAccessGroup -Name "MyAccessGroup" +Removes the access group with the name "MyAccessGroup". +``` ## PARAMETERS -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Id -{{ Fill Id Description }} +The ID of the access group to remove. +This parameter is mandatory when using the 'Id' parameter set. ```yaml Type: Int32 @@ -62,13 +53,14 @@ Aliases: Required: True Position: Named -Default value: None +Default value: 0 Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` ### -Name -{{ Fill Name Description }} +The name of the access group to remove. +This parameter is mandatory when using the 'Name' parameter set. ```yaml Type: String @@ -98,6 +90,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ProgressAction {{ Fill ProgressAction Description }} @@ -118,10 +125,12 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### System.Int32 +### None. ## OUTPUTS -### System.Object +### System.Management.Automation.PSCustomObject ## NOTES +This function requires a valid LogicMonitor API authentication. +Make sure to log in using Connect-LMAccount before running this command. ## RELATED LINKS diff --git a/Documentation/Remove-LMDeviceDatasourceInstance.md b/Documentation/Remove-LMDeviceDatasourceInstance.md index 5b5c9b3..508e8da 100644 --- a/Documentation/Remove-LMDeviceDatasourceInstance.md +++ b/Documentation/Remove-LMDeviceDatasourceInstance.md @@ -15,25 +15,25 @@ Removes a device datasource instance from Logic Monitor. ### Name-dsName ``` Remove-LMDeviceDatasourceInstance -DatasourceName -DeviceName [-WildValue ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] + [-InstanceId ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ### Id-dsName ``` Remove-LMDeviceDatasourceInstance -DatasourceName -DeviceId [-WildValue ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] + [-InstanceId ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ### Name-dsId ``` Remove-LMDeviceDatasourceInstance -DatasourceId -DeviceName [-WildValue ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] + [-InstanceId ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ### Id-dsId ``` Remove-LMDeviceDatasourceInstance -DatasourceId -DeviceId [-WildValue ] - [-ProgressAction ] [-WhatIf] [-Confirm] [] + [-InstanceId ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -44,13 +44,13 @@ It requires valid API credentials and the user must be logged in before running ### EXAMPLE 1 ``` -Remove-LMDeviceDatasourceInstance -DeviceName "MyDevice" -DatasourceName "MyDatasource" -WildValue "12345" +Remove-LMDeviceDatasourceInstance -Name "MyDevice" -DatasourceName "MyDatasource" -WildValue "12345" Removes the device datasource instance with the specified device name, datasource name, and wildcard value. ``` ### EXAMPLE 2 ``` -Remove-LMDeviceDatasourceInstance -DeviceId 123 -DatasourceId 456 -WildValue "67890" +Remove-LMDeviceDatasourceInstance -Id 123 -DatasourceId 456 -WildValue "67890" Removes the device datasource instance with the specified device ID, datasource ID, and wildcard value. ``` @@ -101,8 +101,7 @@ Accept wildcard characters: False ``` ### -DeviceId -Specifies the ID of the device. -This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. +{{ Fill DeviceId Description }} ```yaml Type: Int32 @@ -129,8 +128,7 @@ Accept wildcard characters: False ``` ### -DeviceName -Specifies the name of the device. -This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. +{{ Fill DeviceName Description }} ```yaml Type: String @@ -159,6 +157,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -InstanceId +{{ Fill InstanceId Description }} + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: Id + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -WhatIf Shows what would happen if the cmdlet runs. The cmdlet is not run. diff --git a/Documentation/Remove-LMDeviceDatasourceInstanceGroup.md b/Documentation/Remove-LMDeviceDatasourceInstanceGroup.md new file mode 100644 index 0000000..ce98f63 --- /dev/null +++ b/Documentation/Remove-LMDeviceDatasourceInstanceGroup.md @@ -0,0 +1,197 @@ +--- +external help file: Logic.Monitor-help.xml +Module Name: Logic.Monitor +online version: +schema: 2.0.0 +--- + +# Remove-LMDeviceDatasourceInstanceGroup + +## SYNOPSIS +Removes a LogicMonitor device datasource instance group. + +## SYNTAX + +### Name-dsName +``` +Remove-LMDeviceDatasourceInstanceGroup -DatasourceName -Name -InstanceGroupName + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +### Id-dsName +``` +Remove-LMDeviceDatasourceInstanceGroup -DatasourceName -Id -InstanceGroupName + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +### Name-dsId +``` +Remove-LMDeviceDatasourceInstanceGroup -DatasourceId -Name -InstanceGroupName + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +### Id-dsId +``` +Remove-LMDeviceDatasourceInstanceGroup -DatasourceId -Id -InstanceGroupName + [-ProgressAction ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The Remove-LMDeviceDatasourceInstanceGroup function removes a LogicMonitor device datasource instance group based on the provided parameters. +It requires valid API credentials and a logged-in session. + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-LMDeviceDatasourceInstanceGroup -DatasourceName "CPU" -Name "Server01" -InstanceGroupName "Group1" +Removes the instance group named "Group1" associated with the "CPU" datasource on the device named "Server01". +``` + +### EXAMPLE 2 +``` +Remove-LMDeviceDatasourceInstanceGroup -DatasourceId 123 -Id 456 -InstanceGroupName "Group2" +Removes the instance group named "Group2" associated with the datasource ID 123 on the device ID 456. +``` + +## PARAMETERS + +### -DatasourceName +Specifies the name of the datasource associated with the instance group. +This parameter is mandatory when using the 'Id-dsName' or 'Name-dsName' parameter sets. + +```yaml +Type: String +Parameter Sets: Name-dsName, Id-dsName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasourceId +Specifies the ID of the datasource associated with the instance group. +This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter sets. + +```yaml +Type: Int32 +Parameter Sets: Name-dsId, Id-dsId +Aliases: + +Required: True +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Id +Specifies the ID of the device associated with the instance group. +This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter sets. +This parameter can also be specified using the 'DeviceId' alias. + +```yaml +Type: Int32 +Parameter Sets: Id-dsName, Id-dsId +Aliases: DeviceId + +Required: True +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Specifies the name of the device associated with the instance group. +This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter sets. +This parameter can also be specified using the 'DeviceName' alias. + +```yaml +Type: String +Parameter Sets: Name-dsName, Name-dsId +Aliases: DeviceName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InstanceGroupName +Specifies the name of the instance group to be removed. +This parameter is mandatory. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None. You cannot pipe objects to this function. +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Documentation/Set-LMAccessGroup.md b/Documentation/Set-LMAccessGroup.md index a41bed9..ddd76bd 100644 --- a/Documentation/Set-LMAccessGroup.md +++ b/Documentation/Set-LMAccessGroup.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Set-LMAccessGroup ## SYNOPSIS -{{ Fill in the Synopsis }} +Sets the properties of a LogicMonitor access group. ## SYNTAX @@ -25,55 +25,64 @@ Set-LMAccessGroup [-Name ] [-NewName ] [-Description ] [ ``` ## DESCRIPTION -{{ Fill in the Description }} +The Set-LMAccessGroup function is used to set the properties of a LogicMonitor access group. +It allows you to specify the access group either by its ID or by its name. +You can set the new name, description, and tenant ID for the access group. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +Set-LMAccessGroup -Id 123 -NewName "New Access Group" -Description "This is a new access group" -Tenant "abc123" +Sets the properties of the access group with ID 123. The new name is set to "New Access Group", the description is set to "This is a new access group", and the tenant ID is set to "abc123". ``` -{{ Add example description here }} +### EXAMPLE 2 +``` +Set-LMAccessGroup -Name "Old Access Group" -NewName "New Access Group" -Description "This is a new access group" -Tenant "abc123" +Sets the properties of the access group with name "Old Access Group". The new name is set to "New Access Group", the description is set to "This is a new access group", and the tenant ID is set to "abc123". +``` ## PARAMETERS -### -Description -{{ Fill Description Description }} +### -Id +Specifies the ID of the access group. +This parameter is used when you want to set the properties of the access group by its ID. ```yaml -Type: String -Parameter Sets: (All) +Type: Int32 +Parameter Sets: Id Aliases: Required: False Position: Named -Default value: None -Accept pipeline input: False +Default value: 0 +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Id -{{ Fill Id Description }} +### -Name +Specifies the name of the access group. +This parameter is used when you want to set the properties of the access group by its name. ```yaml -Type: Int32 -Parameter Sets: Id +Type: String +Parameter Sets: Name Aliases: Required: False Position: Named Default value: None -Accept pipeline input: True (ByPropertyName) +Accept pipeline input: False Accept wildcard characters: False ``` -### -Name -{{ Fill Name Description }} +### -NewName +Specifies the new name for the access group. ```yaml Type: String -Parameter Sets: Name +Parameter Sets: (All) Aliases: Required: False @@ -83,8 +92,8 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -NewName -{{ Fill NewName Description }} +### -Description +Specifies the new description for the access group. ```yaml Type: String @@ -99,7 +108,7 @@ Accept wildcard characters: False ``` ### -Tenant -{{ Fill Tenant Description }} +Specifies the tenant ID for the access group. ```yaml Type: String @@ -133,10 +142,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### System.Int32 ## OUTPUTS -### System.Object ## NOTES +This function requires you to be logged in and have valid API credentials. +Use the Connect-LMAccount function to log in before running this command. ## RELATED LINKS diff --git a/Documentation/Set-LMDeviceDatasourceInstance.md b/Documentation/Set-LMDeviceDatasourceInstance.md index 91cb50d..49fb478 100644 --- a/Documentation/Set-LMDeviceDatasourceInstance.md +++ b/Documentation/Set-LMDeviceDatasourceInstance.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Set-LMDeviceDatasourceInstance ## SYNOPSIS -{{ Fill in the Synopsis }} +Sets the properties of a LogicMonitor device datasource instance. ## SYNTAX @@ -16,7 +16,7 @@ schema: 2.0.0 ``` Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-WildValue2 ] [-Description ] [-Properties ] [-StopMonitoring ] [-DisableAlerting ] - [-InstanceGroupId ] -InstanceId -DatasourceName -DeviceName + [-InstanceGroupId ] -InstanceId -DatasourceName -Name [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -24,7 +24,7 @@ Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-W ``` Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-WildValue2 ] [-Description ] [-Properties ] [-StopMonitoring ] [-DisableAlerting ] - [-InstanceGroupId ] -InstanceId -DatasourceName -DeviceId + [-InstanceGroupId ] -InstanceId -DatasourceName -Id [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -32,7 +32,7 @@ Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-W ``` Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-WildValue2 ] [-Description ] [-Properties ] [-StopMonitoring ] [-DisableAlerting ] - [-InstanceGroupId ] -InstanceId -DatasourceId -DeviceName + [-InstanceGroupId ] -InstanceId -DatasourceId -Name [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` @@ -40,31 +40,39 @@ Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-W ``` Set-LMDeviceDatasourceInstance [-DisplayName ] [-WildValue ] [-WildValue2 ] [-Description ] [-Properties ] [-StopMonitoring ] [-DisableAlerting ] - [-InstanceGroupId ] -InstanceId -DatasourceId -DeviceId + [-InstanceGroupId ] -InstanceId -DatasourceId -Id [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -{{ Fill in the Description }} +The Set-LMDeviceDatasourceInstance function is used to set the properties of a LogicMonitor device datasource instance. +It allows you to update the display name, wild values, description, custom properties, monitoring and alerting settings, and instance group ID of the specified instance. ## EXAMPLES -### Example 1 -```powershell -PS C:\> {{ Add example code here }} +### EXAMPLE 1 +``` +Set-LMDeviceDatasourceInstance -InstanceId 12345 -DisplayName "New Instance Name" -Description "Updated instance description" +``` + +This example sets the display name and description of the instance with ID 12345. + +### EXAMPLE 2 +``` +Get-LMDevice -Name "MyDevice" | Set-LMDeviceDatasourceInstance -DatasourceName "MyDatasource" -DisplayName "New Instance Name" ``` -{{ Add example description here }} +This example retrieves the device with the name "MyDevice" and sets the display name of the instance associated with the datasource "MyDatasource". ## PARAMETERS -### -Confirm -Prompts you for confirmation before running the cmdlet. +### -DisplayName +Specifies the new display name for the instance. ```yaml -Type: SwitchParameter +Type: String Parameter Sets: (All) -Aliases: cf +Aliases: Required: False Position: Named @@ -73,53 +81,56 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -DatasourceId -{{ Fill DatasourceId Description }} +### -WildValue +Specifies the first wild value for the instance. ```yaml Type: String -Parameter Sets: Name-dsId +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` +### -WildValue2 +Specifies the second wild value for the instance. + ```yaml Type: String -Parameter Sets: Id-dsId +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -DatasourceName -{{ Fill DatasourceName Description }} +### -Description +Specifies the description for the instance. ```yaml Type: String -Parameter Sets: Name-dsName, Id-dsName +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Description -{{ Fill Description Description }} +### -Properties +Specifies a hashtable of custom properties for the instance. ```yaml -Type: String +Type: Hashtable Parameter Sets: (All) Aliases: @@ -130,161 +141,167 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -DeviceId -{{ Fill DeviceId Description }} +### -StopMonitoring +Specifies whether to stop monitoring the instance. +This parameter accepts $true or $false. ```yaml -Type: String -Parameter Sets: Id-dsName +Type: Boolean +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` +### -DisableAlerting +Specifies whether to disable alerting for the instance. +This parameter accepts $true or $false. + ```yaml -Type: String -Parameter Sets: Id-dsId +Type: Boolean +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -DeviceName -{{ Fill DeviceName Description }} +### -InstanceGroupId +Specifies the ID of the instance group to which the instance belongs. ```yaml Type: String -Parameter Sets: Name-dsName, Name-dsId +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -DisableAlerting -{{ Fill DisableAlerting Description }} +### -InstanceId +Specifies the ID of the instance to update. +This parameter is mandatory and can be provided via pipeline. ```yaml -Type: Boolean +Type: String Parameter Sets: (All) Aliases: -Required: False +Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -DisplayName -{{ Fill DisplayName Description }} +### -DatasourceName +Specifies the name of the datasource associated with the instance. +This parameter is mandatory when using the 'Name-dsName' parameter set. ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: Name-dsName, Id-dsName Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -InstanceGroupId -{{ Fill InstanceGroupId Description }} +### -DatasourceId +Specifies the ID of the datasource associated with the instance. +This parameter is mandatory when using the 'Id-dsId' or 'Name-dsId' parameter set. ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: Name-dsId Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -InstanceId -{{ Fill InstanceId Description }} - ```yaml Type: String -Parameter Sets: (All) -Aliases: Id +Parameter Sets: Id-dsId +Aliases: Required: True Position: Named Default value: None -Accept pipeline input: True (ByPropertyName) +Accept pipeline input: False Accept wildcard characters: False ``` -### -Properties -{{ Fill Properties Description }} +### -Id +Specifies the ID of the device associated with the instance. +This parameter is mandatory when using the 'Id-dsId' or 'Id-dsName' parameter set. +This parameter can also be specified using the 'DeviceId' alias. ```yaml -Type: Hashtable -Parameter Sets: (All) -Aliases: +Type: String +Parameter Sets: Id-dsName +Aliases: DeviceId -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -StopMonitoring -{{ Fill StopMonitoring Description }} - ```yaml -Type: Boolean -Parameter Sets: (All) -Aliases: +Type: String +Parameter Sets: Id-dsId +Aliases: DeviceId -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. +### -Name +Specifies the name of the device associated with the instance. +This parameter is mandatory when using the 'Name-dsName' or 'Name-dsId' parameter set. +This parameter can also be specified using the 'DeviceName' alias. ```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi +Type: String +Parameter Sets: Name-dsName, Name-dsId +Aliases: DeviceName -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -WildValue -{{ Fill WildValue Description }} +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. ```yaml -Type: String +Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: wi Required: False Position: Named @@ -293,13 +310,13 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -WildValue2 -{{ Fill WildValue2 Description }} +### -Confirm +Prompts you for confirmation before running the cmdlet. ```yaml -Type: String +Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: cf Required: False Position: Named @@ -328,10 +345,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### System.String ## OUTPUTS -### System.Object ## NOTES ## RELATED LINKS diff --git a/README.md b/README.md index 2f2fd54..96109b2 100644 --- a/README.md +++ b/README.md @@ -409,7 +409,6 @@ This change aims to enhance visibility within the community and to foster a more We appreciate your continued support and enthusiasm for the Logic.Monitor PowerShell module. Your contributions and feedback are vital to the success of this project, and we look forward to seeing how the module evolves with your participation. -## 6.1 ## 6.1 ### New Cmdlets: - **Get-LMAccessGroup**: This cmdlet will retrieve data for specified LogicMonitor access groups. You can retrieve all access groups or limit the results using *-Id*, *-Name* or *-Filter* parameters.