From c4bc03477b54bb55fadffd464b7ffd5355fd4dcc Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Tue, 7 Dec 2021 14:37:25 +0100 Subject: [PATCH 001/110] Update publish_production.yml --- .github/workflows/publish_production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 1322279..4ba1430 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -19,7 +19,7 @@ jobs: Install-Module platyPS,BuildHelpers -Force -SkipPublisherCheck -Scope CurrentUser & $env:GITHUB_WORKSPACE/Build/New-TeamViewerPSPackage.ps1 -Verbose - - name: Publish to poshtestgallery.com + - name: Publish to powershellgallery.com env: NUGET_APIKEY_PRODUCTION: ${{ secrets.NUGET_APIKEY_PRODUCTION }} shell: pwsh From d8318b05fee50eeeb1ccbfb1e840a953ec6d8079 Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Fri, 8 Apr 2022 13:23:51 +0200 Subject: [PATCH 002/110] Adds `Get-TeamViewerConnectionReport` cmdlet --- Build/New-TeamViewerPSPackage.ps1 | 3 +- .../ConvertTo-TeamViewerConnectionReport.ps1 | 30 ++ .../Public/Get-TeamViewerConnectionReport.ps1 | 149 +++++++ TeamViewerPS/TeamViewerPS.Types.ps1 | 5 + TeamViewerPS/TeamViewerPS.psm1 | 4 +- .../Get-TeamViewerConnectionReport.Tests.ps1 | 229 +++++++++++ .../Get-TeamViewerConnectionReport.md | 388 ++++++++++++++++++ 7 files changed, 805 insertions(+), 3 deletions(-) create mode 100644 TeamViewerPS/Private/ConvertTo-TeamViewerConnectionReport.ps1 create mode 100644 TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1 create mode 100644 TeamViewerPS/TeamViewerPS.Types.ps1 create mode 100644 Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 create mode 100644 docs/commands/Get-TeamViewerConnectionReport.md diff --git a/Build/New-TeamViewerPSPackage.ps1 b/Build/New-TeamViewerPSPackage.ps1 index 9bd7313..a0b8be5 100644 --- a/Build/New-TeamViewerPSPackage.ps1 +++ b/Build/New-TeamViewerPSPackage.ps1 @@ -19,6 +19,7 @@ New-Item -Type Directory "$BuildOutputPath/TeamViewerPS" | Out-Null # Compile all functions into a single psm file $targetFile = "$BuildOutputPath/TeamViewerPS/TeamViewerPS.psm1" Write-Verbose "Compiling single-file TeamViewer module." +$ModuleTypes = @(Get-ChildItem -Path "$repoPath/TeamViewerPS/TeamViewerPS.Types.ps1") $PrivateFunctions = @(Get-ChildItem ` -Path "$repoPath/TeamViewerPS/Private/*.ps1" ` -ErrorAction SilentlyContinue) @@ -27,7 +28,7 @@ $PublicFunctions = @(Get-ChildItem ` -Path "$repoPath/TeamViewerPS/Public/*.ps1" ` -ErrorAction SilentlyContinue) Write-Verbose "Found $($PublicFunctions.Count) public function files." -@($PrivateFunctions + $PublicFunctions) | ` +@($ModuleTypes + $PrivateFunctions + $PublicFunctions) | ` Get-Content -Raw | ` ForEach-Object { $_; "`r`n" } | ` Set-Content -Path $targetFile -Encoding utf8NoBOM diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerConnectionReport.ps1 b/TeamViewerPS/Private/ConvertTo-TeamViewerConnectionReport.ps1 new file mode 100644 index 0000000..cfc33af --- /dev/null +++ b/TeamViewerPS/Private/ConvertTo-TeamViewerConnectionReport.ps1 @@ -0,0 +1,30 @@ +function ConvertTo-TeamViewerConnectionReport { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.id + UserId = $InputObject.userid + UserName = $InputObject.username + DeviceId = $InputObject.deviceid + DeviceName = $InputObject.devicename + GroupId = $InputObject.groupid + GroupName = $InputObject.groupname + SupportSessionType = [TeamViewerConnectionReportSessionType]$InputObject.support_session_type + StartDate = $InputObject.start_date | ConvertTo-DateTime + EndDate = $InputObject.end_date | ConvertTo-DateTime + SessionCode = $InputObject.session_code + Fee = $InputObject.fee + BillingState = $InputObject.billing_state + Currency = $InputObject.currency + Notes = $InputObject.notes + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ConnectionReport') + Write-Output $result + } +} diff --git a/TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1 b/TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1 new file mode 100644 index 0000000..391e359 --- /dev/null +++ b/TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1 @@ -0,0 +1,149 @@ +function Get-TeamViewerConnectionReport { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $false)] + [string] + $UserName, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("User")] + [object] + $UserId, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("Group")] + [object] + $GroupId, + + [Parameter(Mandatory = $false)] + [string] + $DeviceName, + + [Parameter(Mandatory = $false)] + [int] + $DeviceId, + + [Parameter(Mandatory = $false)] + [switch] + $WithSessionCode, + + [Parameter(Mandatory = $false)] + [switch] + $WithoutSessionCode, + + [Parameter(Mandatory = $false)] + [string] + $SessionCode, + + [Parameter(Mandatory = $false)] + [TeamViewerConnectionReportSessionType] + $SupportSessionType, + + [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] + [DateTime] + $StartDate, + + [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [DateTime] + $EndDate = (Get-Date), + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 12)] + [int] + $Months, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 31)] + [int] + $Days, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 24)] + [int] + $Hours, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 60)] + [int] + $Minutes, + + [Parameter(Mandatory = $false)] + [ValidateRange(1, [int]::MaxValue)] + [int] + $Limit + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/reports/connections"; + + $parameters = @{} + + if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { + $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) + } + if ($StartDate -And $EndDate -And $StartDate -lt $EndDate) { + $parameters.from_date = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + $parameters.to_date = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + } + + if ($UserName) { + $parameters.username = $UserName + } + + if ($UserId) { + $parameters.userid = $UserId | Resolve-TeamViewerUserId + } + + if ($DeviceName) { + $parameters.devicename = $DeviceName + } + + if ($DeviceId) { + $parameters.deviceid = $DeviceId + } + + if ($GroupId) { + $parameters.groupid = $GroupId | Resolve-TeamViewerGroupId + } + + if ($WithSessionCode -And !$WithoutSessionCode) { + $parameters.has_code = $true + } + elseif ($WithoutSessionCode -And !$WithSessionCode) { + $parameters.has_code = $false + } + + if ($SessionCode) { + $parameters.session_code = $SessionCode + } + + if ($SupportSessionType) { + $parameters.support_session_type = [int]$SupportSessionType + } + + $remaining = $Limit + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $results = ($response.records | ConvertTo-TeamViewerConnectionReport) + if ($Limit) { + Write-Output ($results | Select-Object -First $remaining) + $remaining = $remaining - @($results).Count + } + else { + Write-Output $results + } + $parameters.offset_id = $response.next_offset + } while ($parameters.offset_id -And (!$Limit -Or $remaining -gt 0)) +} diff --git a/TeamViewerPS/TeamViewerPS.Types.ps1 b/TeamViewerPS/TeamViewerPS.Types.ps1 new file mode 100644 index 0000000..cabf757 --- /dev/null +++ b/TeamViewerPS/TeamViewerPS.Types.ps1 @@ -0,0 +1,5 @@ +enum TeamViewerConnectionReportSessionType { + RemoteConnection = 1 + RemoteSupportActive = 2 + RemoteSupportActiveSdk = 3 +} diff --git a/TeamViewerPS/TeamViewerPS.psm1 b/TeamViewerPS/TeamViewerPS.psm1 index d4da497..7106f40 100644 --- a/TeamViewerPS/TeamViewerPS.psm1 +++ b/TeamViewerPS/TeamViewerPS.psm1 @@ -1,6 +1,6 @@ - +$ModuleTypes = @( Get-ChildItem -Path "$PSScriptRoot/TeamViewerPS.Types.ps1" -ErrorAction SilentlyContinue ) $PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -ErrorAction SilentlyContinue ) $PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -ErrorAction SilentlyContinue ) -@($PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } +@($ModuleTypes + $PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * diff --git a/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 b/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 new file mode 100644 index 0000000..fa5847f --- /dev/null +++ b/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 @@ -0,0 +1,229 @@ +BeforeAll { + . "$PSScriptRoot/../../TeamViewerPS/TeamViewerPS.Types.ps1" + . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { @{ + records = @( + @{ + id = '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' + userid = 'u1234' + username = 'test-user1' + deviceid = 'd111' + devicename = 'test-device1' + start_date = '2017-02-03T14:10:50Z' + end_date = '2017-02-03T14:11:01Z' + support_session_type = 1 + }, + @{ + id = '5ae6d2a9-57e9-4c62-b236-280390954b6f' + userid = 'u5678' + username = 'test-user2' + deviceid = 'd222' + devicename = 'test-device2' + start_date = '2017-02-03T14:10:50Z' + end_date = '2017-02-03T14:11:01Z' + support_session_type = 1 + } + ) + } } +} + +Describe 'Get-TeamViewerConnectionReport' { + It 'Should call the correct API endpoint to list connection reports' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/reports/connections' -And ` + $Method -eq 'Get' } + } + + It 'Should return ConnectionReport objects' { + $result = Get-TeamViewerConnectionReport -ApiToken $testApiToken + $result | Should -HaveCount 2 + $result[0].PSObject.TypeNames | Should -Contain 'TeamViewerPS.ConnectionReport' + } + + It 'Should fetch consecutive pages' { + Mock Invoke-TeamViewerRestMethod { @{ + records = @( + @{ + id = '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' + userid = 'u1234' + username = 'test-user1' + deviceid = 'd111' + devicename = 'test-device1' + start_date = '2017-02-03T14:10:50Z' + end_date = '2017-02-03T14:11:01Z' + support_session_type = 1 + } + ) + next_offset = '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' + } } + Mock Invoke-TeamViewerRestMethod { @{ + records = @( + @{ + id = '5ae6d2a9-57e9-4c62-b236-280390954b6f' + userid = 'u5678' + username = 'test-user2' + deviceid = 'd222' + devicename = 'test-device2' + start_date = '2017-02-03T14:10:50Z' + end_date = '2017-02-03T14:11:01Z' + support_session_type = 1 + } + ) + next_offset = '5ae6d2a9-57e9-4c62-b236-280390954b6f' + } } -ParameterFilter { $Body.offset_id -eq '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' } + Mock Invoke-TeamViewerRestMethod { @{ + records = @( + @{ + id = '018d007c-9faf-474a-b39a-4021251860e7' + userid = 'u9012' + username = 'test-user3' + deviceid = 'd333' + devicename = 'test-device3' + start_date = '2017-02-03T14:10:50Z' + end_date = '2017-02-03T14:11:01Z' + support_session_type = 1 + } + ) + } } -ParameterFilter { $Body.offset_id -eq '5ae6d2a9-57e9-4c62-b236-280390954b6f' } + + $result = Get-TeamViewerConnectionReport -ApiToken $testApiToken + $result | Should -HaveCount 3 + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 3 -Scope It + } + + Context 'Filtering' { + BeforeAll { + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body; @{ records = @() } } + } + + It 'Should allow to filter by username' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -UserName 'test-user1' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.username | Should -Be 'test-user1' + } + + It 'Should allow to filter by userid' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -UserId 'u1234' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.userid | Should -Be 'u1234' + } + + It 'Should allow to filter by groupid' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -GroupId 'g1234' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.groupid | Should -Be 'g1234' + } + + It 'Should allow to filter by device name' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -DeviceName 'test-device1' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.devicename | Should -Be 'test-device1' + } + + It 'Should allow to filter by deviceid' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -DeviceId 111 + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.deviceid | Should -Be '111' + } + + It 'Should allow to filter by session code' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -SessionCode 's112233' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.session_code | Should -Be 's112233' + } + + It 'Should allow to filter for entries with session code' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -WithSessionCode + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.has_code | Should -Be $true + } + + It 'Should allow to filter for entries without session code' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -WithoutSessionCode + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.has_code | Should -Be $false + } + + It 'Should allow to filter by support session type' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -SupportSessionType 'RemoteSupportActiveSdk' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It + $mockArgs.Body.support_session_type | Should -Be 3 + } + } + + Context 'Time frame' { + BeforeAll { + $testStartDate = Get-Date + $testEndDate = $testStartDate.AddDays(1) + $null = $testEndDate + + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body; @{ records = @() } } + + function Get-TestStartEndDate { + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = $mockArgs.Body + $body.from_date | Should -Not -BeNullOrEmpty + $body.to_date | Should -Not -BeNullOrEmpty + $startDate = [System.DateTime]::ParseExact($body.from_date, 'yyyy-MM-ddTHH:mm:ssZ', [CultureInfo]::InvariantCulture) + $endDate = [System.DateTime]::ParseExact($body.to_date, 'yyyy-MM-ddTHH:mm:ssZ', [CultureInfo]::InvariantCulture) + return @{ + StartDate = $startDate + EndDate = $endDate + Diff = New-TimeSpan -Start $startDate -End $endDate + } + } + } + + It 'Should allow to specify an absolute start and end time' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken ` + -StartDate $testStartDate -EndDate $testEndDate + $dates = Get-TestStartEndDate + $dates.StartDate | Should -Be $testStartDate.AddTicks(-1 * ($testStartDate.Ticks % [TimeSpan]::TicksPerSecond)) + $dates.EndDate | Should -Be $testEndDate.AddTicks(-1 * ($testEndDate.Ticks % [TimeSpan]::TicksPerSecond)) + } + + It 'Should allow to set a start date months in the past' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -Months 3 + $dates = Get-TestStartEndDate + $dates.Diff.TotalDays | Should -BeLessOrEqual (3 * 31) + $dates.Diff.TotalDays | Should -BeGreaterOrEqual (3 * 28) + } + + It 'Should allow to set a start date days in the past' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -Days 7 + $dates = Get-TestStartEndDate + $dates.Diff.TotalDays | Should -Be 7 + } + + It 'Should allow to set a start date hours in the past' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -Hours 12 + $dates = Get-TestStartEndDate + $dates.Diff.TotalHours | Should -Be 12 + } + + It 'Should allow to set a start date minutes in the past' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken -Minutes 45 + $dates = Get-TestStartEndDate + $dates.Diff.TotalMinutes | Should -Be 45 + } + + It 'Should not restrict timeframe if no start and end date are given' { + Get-TeamViewerConnectionReport -ApiToken $testApiToken + $body = $mockArgs.Body + $body.from_date | Should -BeNullOrEmpty + $body.to_date | Should -BeNullOrEmpty + } + } +} diff --git a/docs/commands/Get-TeamViewerConnectionReport.md b/docs/commands/Get-TeamViewerConnectionReport.md new file mode 100644 index 0000000..2c0200d --- /dev/null +++ b/docs/commands/Get-TeamViewerConnectionReport.md @@ -0,0 +1,388 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerConnectionReport + +## SYNOPSIS + +Returns the TeamViewer session reports of the company associated with the given +API token. + +## SYNTAX + +### AbsoluteDates + +```powershell +Get-TeamViewerConnectionReport -ApiToken [-UserName ] [-UserId ] + [-GroupId ] [-DeviceName ] [-DeviceId ] [-WithSessionCode] [-WithoutSessionCode] + [-SessionCode ] [-SupportSessionType ] -StartDate + [-EndDate ] [-Limit ] [] +``` + +### RelativeDates + +```powershell +Get-TeamViewerConnectionReport -ApiToken [-UserName ] [-UserId ] + [-GroupId ] [-DeviceName ] [-DeviceId ] [-WithSessionCode] [-WithoutSessionCode] + [-SessionCode ] [-SupportSessionType ] [-EndDate ] + [-Months ] [-Days ] [-Hours ] [-Minutes ] [-Limit ] [] +``` + +## DESCRIPTION + +Returns a list of TeamViewer session reports. The list can optionally be filtered +using the given parameters. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerConnectionReport +``` + +List all available connection reports + +### Example 2 + +```powershell +PS /> Get-TeamViewerConnectionReport -Days 14 +``` + +List connection reports of the last 2 weeks + +### Example 3 + +```powershell +PS /> Get-TeamViewerConnectionReport -SessionId s1122344 +``` + +List connection reports for the given session identifier. + +### Example 4 + +```powershell +PS /> Get-TeamViewerConnectionReport -UserId u1234 -StartDate "2021-05-01 13:00" +``` + +List reports for connections of the TeamViewer account with the given user ID and +that were initiated on or after May 1st, 2021 1pm. +If specified like this, dates/times use the timezone currently configured in +your Powershell. For UTC, just add a `Z` at the end. + +### Example 5 + +```powershell +PS /> Get-TeamViewerConnectionReport ` + -Group (Get-TeamViewerGroup -Name "My Computers" | Select-Object -First 1) ` + -StartDate "2021-04-01" -EndDate "2021-04-02" +``` + +List connection reports for devices in a group named `My Computers` and that +have happened between April 1st and April 2nd 2021. +This example shows the interaction with the `Get-TeamViewerGroup` cmdlet. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Days + +Sets the start date to the given number of days before the end date. +If no `-EndDate` is given, this is the number of days in the past until now. + +```yaml +Type: Int32 +Parameter Sets: RelativeDates +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DeviceId + +Filter the list of connection reports by the given device identifier. This +needs to be the TeamViewer ID of the device. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DeviceName + +Filter the list of connection reports by the given device name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -EndDate + +Sets the end for the date range of connection reports to fetch. Defaults to now. +To be included in the results the connection is required to be ended before this +date/time. + +```yaml +Type: DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -GroupId + +Filter the list of connection reports by the given group ID. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Group + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Hours + +Sets the start date to the given number of hours before the end date. +If no `-EndDate` is given, this is the number of hours in the past until now. + +```yaml +Type: Int32 +Parameter Sets: RelativeDates +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Limit + +Optionally limit the results to the given number. If the limit is reached the +function stops and won't fetch more entries. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Minutes + +Sets the start date to the given number of minutes before the end date. +If no `-EndDate` is given, this is the number of minutes in the past until now. + +```yaml +Type: Int32 +Parameter Sets: RelativeDates +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Months + +Sets the start date to the given number of months before the end date. +If no `-EndDate` is given, this is the number of months in the past until now. + +```yaml +Type: Int32 +Parameter Sets: RelativeDates +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SessionCode + +Filter the list of connection reports by the given session-code. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -StartDate + +Sets the start for the date range of connection reports to get. +To be included in the results the connection is required to be started on or +after this date/time. + +```yaml +Type: DateTime +Parameter Sets: AbsoluteDates +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SupportSessionType + +Filter the list of connection reports by the given session type. + +```yaml +Type: TeamViewerConnectionReportSessionType +Parameter Sets: (All) +Aliases: +Accepted values: RemoteConnection, RemoteSupportActive, RemoteSupportActiveSdk + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserId + +Filter the list of connection reports by the given user ID. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: User + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserName + +Filter the list of connection reports by the given user name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WithSessionCode + +Filter the list of connection reports to only contain entries that have a +session code. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WithoutSessionCode + +Filter the list of connection reports to only contain entries that do not have a +session code assiciated to. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +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 + +## NOTES + +## RELATED LINKS From e70770b8c2e46203a9c7180c17e0c9a71359cdb8 Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Mon, 11 Apr 2022 15:44:07 +0200 Subject: [PATCH 003/110] Fixing the `Group` parameter of `Remove-TeamViewerManagedDevice` to be mandatory --- TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 | 2 +- docs/commands/Remove-TeamViewerManagedDevice.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 b/TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 index 48b2d1b..9ef8364 100644 --- a/TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 +++ b/TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 @@ -11,7 +11,7 @@ function Remove-TeamViewerManagedDevice { [object] $Device, - [Parameter()] + [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] [Alias("GroupId")] [object] diff --git a/docs/commands/Remove-TeamViewerManagedDevice.md b/docs/commands/Remove-TeamViewerManagedDevice.md index 5446e1f..33ec45c 100644 --- a/docs/commands/Remove-TeamViewerManagedDevice.md +++ b/docs/commands/Remove-TeamViewerManagedDevice.md @@ -96,7 +96,7 @@ Type: Object Parameter Sets: (All) Aliases: GroupId -Required: False +Required: True Position: 2 Default value: None Accept pipeline input: False From 70f854bf6fdc26885336721cf03235c3bf55d690 Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Mon, 11 Apr 2022 15:49:46 +0200 Subject: [PATCH 004/110] Update CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c9467..c0be073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 1.4.0 (planned) + +### Fixed + +- Fixed `-Group` parameter of `Remove-TeamViewerManagedDevice` to be mandatory. + +### Added + +- Added `Get-TeamViewerConnectionReport` cmdlet to fetch TeamViewer session/connection reports. + ## 1.3.1 (2021-11) ### Fixed From 10a867380bdf700b81f1858630bc4ad06f2f3102 Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Mon, 11 Apr 2022 15:54:12 +0200 Subject: [PATCH 005/110] Update about_TeamViewerPS.md --- docs/about_TeamViewerPS.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/about_TeamViewerPS.md b/docs/about_TeamViewerPS.md index 8aba3cf..bcb2575 100644 --- a/docs/about_TeamViewerPS.md +++ b/docs/about_TeamViewerPS.md @@ -143,11 +143,13 @@ The following functions are available in this category: [`Remove-TeamViewerSsoExclusion`](commands/Remove-TeamViewerSsoExclusion.md) -## Event logs +## Event logs & reporting -Retrieve event log entries of a TeamViewer company via the TeamViewer Web +Retrieve event log entries or connection-reports of a TeamViewer company via the TeamViewer Web API. +[`Get-TeamViewerConnectionReport`](commands/Get-TeamViewerConnectionReport.md) + [`Get-TeamViewerEventLog`](commands/Get-TeamViewerEventLog.md) ## Local TeamViewer utilities From a845d0eb02c39b5abf93daaf1be389f9d097e67b Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Mon, 11 Apr 2022 15:55:42 +0200 Subject: [PATCH 006/110] Update Get-TeamViewerConnectionReport.md --- docs/commands/Get-TeamViewerConnectionReport.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/commands/Get-TeamViewerConnectionReport.md b/docs/commands/Get-TeamViewerConnectionReport.md index 2c0200d..463e3a5 100644 --- a/docs/commands/Get-TeamViewerConnectionReport.md +++ b/docs/commands/Get-TeamViewerConnectionReport.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerConnectionReport.md schema: 2.0.0 --- From 2e674d2d8ad07c15d4a9cd2607125e9a915177bb Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Wed, 13 Apr 2022 17:23:34 +0200 Subject: [PATCH 007/110] Update Get-TeamViewerConnectionReport.md --- docs/commands/Get-TeamViewerConnectionReport.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/commands/Get-TeamViewerConnectionReport.md b/docs/commands/Get-TeamViewerConnectionReport.md index 463e3a5..fd820a0 100644 --- a/docs/commands/Get-TeamViewerConnectionReport.md +++ b/docs/commands/Get-TeamViewerConnectionReport.md @@ -58,10 +58,10 @@ List connection reports of the last 2 weeks ### Example 3 ```powershell -PS /> Get-TeamViewerConnectionReport -SessionId s1122344 +PS /> Get-TeamViewerConnectionReport -SessionCode s1122344 ``` -List connection reports for the given session identifier. +List connection reports for the given session code. ### Example 4 From 746987553f81a5a85e2d38897d5594f7b2533d9a Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Tue, 19 Apr 2022 09:04:11 +0200 Subject: [PATCH 008/110] Moving to version 1.4.0 --- TeamViewerPS/TeamViewerPS.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TeamViewerPS/TeamViewerPS.psd1 b/TeamViewerPS/TeamViewerPS.psd1 index a68383d..f87c778 100644 --- a/TeamViewerPS/TeamViewerPS.psd1 +++ b/TeamViewerPS/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '1.3.1' + ModuleVersion = '1.4.0' # Supported PSEditions. # CompatiblePSEditions = @() @@ -18,7 +18,7 @@ CompanyName = 'TeamViewer Germany GmbH' # Copyright statement for this module. - Copyright = '(c) 2021 TeamViewer Germany GmbH. All rights reserved.' + Copyright = '(c) 2021-2022 TeamViewer Germany GmbH. All rights reserved.' # Description of the functionality provided by this module. Description = 'TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally installed TeamViewer client.' From cad59b66386b69e4e6e3e6883f705fb765a14e83 Mon Sep 17 00:00:00 2001 From: Daniel Joos Date: Tue, 19 Apr 2022 09:04:34 +0200 Subject: [PATCH 009/110] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0be073..191b5a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## 1.4.0 (planned) +## 1.4.0 (2022-04-19) ### Fixed From b956c09ead31ff422f1fa3600e80e25a6e7363d8 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Thu, 6 Oct 2022 10:03:54 +0200 Subject: [PATCH 010/110] Update Add-TeamViewerManager.ps1 included adding UserGroups as manager --- TeamViewerPS/Public/Add-TeamViewerManager.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 b/TeamViewerPS/Public/Add-TeamViewerManager.ps1 index d7f83bc..726ae16 100644 --- a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 +++ b/TeamViewerPS/Public/Add-TeamViewerManager.ps1 @@ -23,9 +23,17 @@ function Add-TeamViewerManager { [object] $User, + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId })] + [Alias('UserGroupId')] + [object] + $UserGroup, + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] [Alias("GroupId")] [object] @@ -34,6 +42,7 @@ function Add-TeamViewerManager { [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] [Alias("DeviceId")] [object] @@ -70,6 +79,9 @@ function Add-TeamViewerManager { '*ByUserObject' { $body["accountId"] = $User.Id.TrimStart('u') } + '*ByUserGroupId' { + $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId + } } if ($Permissions) { From c70cd6cb1199f8feb171815ca7b2b12e0fe8fda4 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Mon, 10 Oct 2022 09:11:05 +0200 Subject: [PATCH 011/110] updated md-Help "Add-TeamViewerManager.md" --- docs/commands/Add-TeamViewerManager.md | 52 ++++++++++++++++++-------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/docs/commands/Add-TeamViewerManager.md b/docs/commands/Add-TeamViewerManager.md index 4f4b9cb..e3dddd2 100644 --- a/docs/commands/Add-TeamViewerManager.md +++ b/docs/commands/Add-TeamViewerManager.md @@ -14,47 +14,53 @@ Add a manager to a managed device or managed group. ## SYNTAX ### Device_ByAccountId (Default) - -```powershell +``` Add-TeamViewerManager -ApiToken -AccountId -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByAccountId - -```powershell +``` Add-TeamViewerManager -ApiToken -AccountId -Group [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByManagerId - -```powershell +``` Add-TeamViewerManager -ApiToken -Manager -Group [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Device_ByManagerId - -```powershell +``` Add-TeamViewerManager -ApiToken -Manager -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByUserObject - -```powershell +``` Add-TeamViewerManager -ApiToken -User -Group [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Device_ByUserObject - -```powershell +``` Add-TeamViewerManager -ApiToken -User -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` +### Device_ByUserGroupId +``` +Add-TeamViewerManager -ApiToken -UserGroup -Device [-Permissions ] + [-WhatIf] [-Confirm] [] +``` + +### Group_ByUserGroupId +``` +Add-TeamViewerManager -ApiToken -UserGroup -Group [-Permissions ] + [-WhatIf] [-Confirm] [] +``` + ## DESCRIPTION Adds a manager to a managed device or a managed group. Managers can either be @@ -82,7 +88,7 @@ PS /> Add-TeamViewerManager -Group '9fd16af0-c224-4242-998e-a7138b038dbb' -Manag Add the manager with the given Manager ID to the managed group with the given group ID. -### Example 2 +### Example 3 ```powershell PS /> Add-TeamViewerManager -Group '9fd16af0-c224-4242-998e-a7138b038dbb' -AccountId 1234 @@ -149,7 +155,7 @@ object that has been received using other module functions. ```yaml Type: Object -Parameter Sets: Device_ByAccountId, Device_ByManagerId, Device_ByUserObject +Parameter Sets: Device_ByAccountId, Device_ByManagerId, Device_ByUserObject, Device_ByUserGroupId Aliases: DeviceId Required: True @@ -167,7 +173,7 @@ object that has been received using other module functions. ```yaml Type: Object -Parameter Sets: Group_ByAccountId, Group_ByManagerId, Group_ByUserObject +Parameter Sets: Group_ByAccountId, Group_ByManagerId, Group_ByUserObject, Group_ByUserGroupId Aliases: GroupId Required: True @@ -248,6 +254,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -UserGroup +UserGroup object as returned from `Get-TeamViewerUserGroup` or Id of the UserGroup which should be added as manager of the targeted managed group or managed device. + +```yaml +Type: Object +Parameter Sets: Device_ByUserGroupId, Group_ByUserGroupId +Aliases: UserGroupId + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -WhatIf Shows what would happen if the cmdlet runs. @@ -266,7 +287,6 @@ 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 From d1d2d5006d32e5828456d3cb302ecf79062100e8 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Tue, 11 Oct 2022 15:17:35 +0200 Subject: [PATCH 012/110] bug fix line 80. $User is already ID --- TeamViewerPS/Public/Add-TeamViewerManager.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 b/TeamViewerPS/Public/Add-TeamViewerManager.ps1 index 726ae16..2a96adc 100644 --- a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 +++ b/TeamViewerPS/Public/Add-TeamViewerManager.ps1 @@ -77,7 +77,7 @@ function Add-TeamViewerManager { $body["id"] = $Manager | Resolve-TeamViewerManagerId } '*ByUserObject' { - $body["accountId"] = $User.Id.TrimStart('u') + $body["accountId"] = $User.TrimStart('u') } '*ByUserGroupId' { $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId From 45c71a5d960832968125ea9674d84cd835f4a425 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Thu, 20 Oct 2022 10:03:14 +0200 Subject: [PATCH 013/110] Update Add-TeamViewerManager.ps1 --- TeamViewerPS/Public/Add-TeamViewerManager.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 b/TeamViewerPS/Public/Add-TeamViewerManager.ps1 index 2a96adc..bbec546 100644 --- a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 +++ b/TeamViewerPS/Public/Add-TeamViewerManager.ps1 @@ -77,7 +77,7 @@ function Add-TeamViewerManager { $body["id"] = $Manager | Resolve-TeamViewerManagerId } '*ByUserObject' { - $body["accountId"] = $User.TrimStart('u') + $body["accountId"] = ( $User | Resolve-TeamViewerUserId ).TrimStart('u') } '*ByUserGroupId' { $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId From dc7d7766864d03165f01c74aea43585b0fd39073 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Mon, 24 Oct 2022 13:03:19 +0200 Subject: [PATCH 014/110] added Remove-TeamViewerUser --- TeamViewerPS/Public/Remove-TeamViewerUser.ps1 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 TeamViewerPS/Public/Remove-TeamViewerUser.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerUser.ps1 b/TeamViewerPS/Public/Remove-TeamViewerUser.ps1 new file mode 100644 index 0000000..f88435b --- /dev/null +++ b/TeamViewerPS/Public/Remove-TeamViewerUser.ps1 @@ -0,0 +1,36 @@ +function Remove-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [Alias("Id")] + [object] + $User, + + [Parameter()] + [switch] + $Permanent + ) + Process { + $userId = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" + + if ($Permanent) { + $resourceUri += '?isPermanentDelete=true' + } + + if ($PSCmdlet.ShouldProcess($userId, "Remove user")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} From ce38e6fb0a82ffcb3f89bb62bd48e3a4da218a58 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Mon, 24 Oct 2022 13:14:00 +0200 Subject: [PATCH 015/110] added test for Remove-TeamViewerUser --- Tests/Public/Remove-TeamViewerUser.Tests.ps1 | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Tests/Public/Remove-TeamViewerUser.Tests.ps1 diff --git a/Tests/Public/Remove-TeamViewerUser.Tests.ps1 b/Tests/Public/Remove-TeamViewerUser.Tests.ps1 new file mode 100644 index 0000000..78f6038 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerUser.Tests.ps1 @@ -0,0 +1,57 @@ +BeforeAll { + . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerUser.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { } +} + +Describe 'Remove-TeamViewerUser' { + It 'Should call the correct API endpoint' { + Remove-TeamViewerUser -ApiToken $testApiToken -User 'u1234' + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/users/u1234' -And ` + $Method -eq 'Delete' } + } + + It 'Should accept group objects' { + $testUser = @{ id = 'u1234' } | ConvertTo-TeamViewerUser + Remove-TeamViewerUser -ApiToken $testApiToken -User $testUser + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/users/u1234' -And ` + $Method -eq 'Delete' } + } + + It 'Should fail for invalid group identifiers' { + { Remove-TeamViewerUser -ApiToken $testApiToken -User 'invalid1234' } | Should -Throw + } + + It 'Should accept pipeline input' { + $testUser = @{ id = 'u1234' } | ConvertTo-TeamViewerUser + $testUser | Remove-TeamViewerUser -ApiToken $testApiToken + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/users/u1234' -And ` + $Method -eq 'Delete' } + } + + It 'Should accept switch parameter "Permanent"' { + $testUser = @{ id = 'u1234' } | ConvertTo-TeamViewerUser + Remove-TeamViewerUser -ApiToken $testApiToken -User $testUser -Permanent + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/users/u1234?isPermanentDelete=true' -And ` + $Method -eq 'Delete' } + } +} From 2b0c9c835e95b0feb5103b5d63c98bbe68df3411 Mon Sep 17 00:00:00 2001 From: Maximilian Otter Date: Mon, 24 Oct 2022 13:33:58 +0200 Subject: [PATCH 016/110] aded mdhelp for Remove-TeamViewerUser --- docs/commands/Remove-TeamViewerUser.md | 131 +++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 docs/commands/Remove-TeamViewerUser.md diff --git a/docs/commands/Remove-TeamViewerUser.md b/docs/commands/Remove-TeamViewerUser.md new file mode 100644 index 0000000..e37553e --- /dev/null +++ b/docs/commands/Remove-TeamViewerUser.md @@ -0,0 +1,131 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerUser + +## SYNOPSIS + +Removes a user from the TeamViewer tenant + +## SYNTAX + +``` +Remove-TeamViewerUser [-ApiToken] [-User] [-Permanent] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION + +Removes an existing user from the TeamViewer tenant. +If the switch -Permanent is added the user is delete from TeamViewer completely, otherwise it is only removed from the tenant. + +## EXAMPLES + +### Example 1 + +```powershell +PS C:\> Remove-TeamViewerUser -User 'u1234' +``` + + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -Permanent + +Deletes the user account completely instead of just removing it from the tenant. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -User + +Object that can be used to identify the user. +This can either be the user ID or a user object that has been received using other module functions + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +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 +``` + +### 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.Object + +## OUTPUTS + +## NOTES + +## RELATED LINKS From 8a1e1cb3e103586211fe37edf83439f4d57bc182 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 29 Mar 2023 09:24:07 +0200 Subject: [PATCH 017/110] Updated license file (no legal change) --- LICENSE | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index d0185a8..39d208c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,6 @@ -Copyright (c) 2021 TeamViewer Germany GmbH +MIT License + +Copyright (c) 2018-2023 TeamViewer Germany GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -7,16 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -When reusing or redistributing the software please respect any licenses of -included software from third parties, if applicable. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 61d23ede3522933278a8b6cb0dae21e3bc858df8 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Sat, 22 Apr 2023 09:20:48 +0200 Subject: [PATCH 018/110] Adapt files in .vscode --- .vscode/extensions.json | 5 ++-- .vscode/launch.json | 33 ++++++++-------------- .vscode/settings.json | 61 +++++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 55 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 70916b4..f812c74 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,7 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format + // See http://go.microsoft.com/fwlink/?LinkId=827846 for the documentation about the extensions.json format "recommendations": [ "ms-vscode.PowerShell", "DavidAnson.vscode-markdownlint" ] -} \ No newline at end of file +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 275fac9..16824b2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,33 +1,22 @@ { - "version": "0.1.0", - "configurations": [{ - "type": "PowerShell", - "request": "launch", - "name": "PowerShell Pester Tests", - "script": "Invoke-Pester", - "args": [], - "cwd": "${workspaceRoot}" - }, + // See https://go.microsoft.com/fwlink/?linkid=830387 for the documentation about the launch.json format + "version": "0.2.0", + "configurations": [ { + "name": "Test (via Pester)", "type": "PowerShell", "request": "launch", - "name": "PowerShell launch (current file)", - "script": "${file}", - "args": [], - "cwd": "${file}" - }, - { - "type": "PowerShell", - "request": "attach", - "name": "PowerShell attach to host process", - "processId": "${command:PickPSHostProcess}", - "runspaceId": 1 + "script": "Invoke-Pester", + "args": [ + "-Path '${workspaceFolder}' -Output Detailed" + ] }, { + "name": "Run (via PowerShell)", "type": "PowerShell", "request": "launch", - "name": "PowerShell interactive session", - "cwd": "${workspaceRoot}" + "cwd": "${workspaceRoot}", + "args": [] } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index cb4ca7b..ee91085 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,51 +1,52 @@ -// Place your settings in this file to overwrite default and user settings. { + // Place your settings in this file to overwrite default and user settings. + "editor.formatOnSave": true, "files.eol": "\r\n", "files.encoding": "utf8", "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, - - "editor.tabSize": 4, - "editor.insertSpaces": true, - - // https://en.wikipedia.org/wiki/Indentation_style#Styles + "powershell.codeFolding.showLastLine": false, + "powershell.buttons.showPanelMovementButtons": true, "powershell.codeFormatting.preset": "Stroustrup", - "powershell.codeFormatting.ignoreOneLineBlock": true, - "powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1", - + "powershell.codeFormatting.pipelineIndentationStyle": "NoIndentation", + "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.addWhitespaceAroundPipe": true, + "powershell.codeFormatting.alignPropertyValuePairs": true, + "powershell.codeFormatting.autoCorrectAliases": true, + "powershell.codeFormatting.avoidSemicolonsAsLineTerminators": true, + "powershell.codeFormatting.newLineAfterCloseBrace": true, + "powershell.codeFormatting.newLineAfterOpenBrace": true, + "powershell.codeFormatting.trimWhitespaceAroundPipe": true, + "powershell.codeFormatting.useConstantStrings": true, + "powershell.codeFormatting.useCorrectCasing": true, + "powershell.codeFormatting.whitespaceAfterSeparator": true, + "powershell.codeFormatting.whitespaceAroundOperator": true, + "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenParen": true, + "powershell.codeFormatting.whitespaceBetweenParameters": true, + "powershell.codeFormatting.whitespaceInsideBrace": true, "[markdown]": { "editor.tabSize": 2, "editor.trimAutoWhitespace": false, "files.trimTrailingWhitespace": false }, - "[yaml]": { - "editor.tabSize": 2 - }, - "markdownlint.config": { "MD009": false, "MD024": false, "MD025": false, "MD028": false }, - "cSpell.dictionaryDefinitions": [{ - "name": "customDictionary", - "path": "./.spelling" - }], + "[yaml]": { + "editor.tabSize": 2 + }, + "cSpell.dictionaryDefinitions": [ + { + "name": "customDictionary", + "path": "./.spelling" + } + ], "cSpell.dictionaries": [ "customDictionary" ], "cSpell.language": "en" - - // Recomendations for "USER SETTINGS": - // "editor.formatOnType": true, - // "editor.formatOnPaste": true, - // "[markdown]": { - // "editor.wordWrap": "on", - // "editor.renderWhitespace": "boundary", - // "editor.acceptSuggestionOnEnter": "off" - // }, - // "search.exclude": { - // "./Release": true - // } -} \ No newline at end of file +} From bcce2d48f9f1a2ee1b195842e542925e411629cf Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Sat, 22 Apr 2023 11:23:50 +0200 Subject: [PATCH 019/110] Add task "Lint (via PSScriptAnalyzer)" to tasks --- .vscode/tasks.json | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0000d01..a68e5ee 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,19 +1,20 @@ -{ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 for the documentation about the tasks.json format "version": "2.0.0", - "windows": { - "options": { - "shell": { - "executable": "${env:windir}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", - "args": [ - "-NoProfile", - "-ExecutionPolicy", - "Bypass", - "-Command" - ] - } - } - }, "tasks": [ + { + "label": "Lint (via PSScriptAnalyzer)", + "type": "shell", + "command": "Invoke-ScriptAnalyzer -Path '${workspaceFolder}' -Severity Information, Warning, Error -Recurse", + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always" + }, + "problemMatcher": [] + }, { "label": "Clean", "type": "shell", From 4ed3b97559365e332b63818f8fdc5e49a4ab8164 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:00:42 +0200 Subject: [PATCH 020/110] Update CHANGELOG.md Updated due to PR --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 191b5a6..63438a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 1.x.0 (2023-0x-xx) + +### Added + +- Added `Remove-TeamViewerUser` cmdlet to remove user from TeamViewer company. (Thanks @OtterKring) + +### Changed + +- Extended `Add-TeamViewerManager` to add user group as manager. (Thanks @OtterKring) + ## 1.4.0 (2022-04-19) ### Fixed From 46dab6d6fbaf1443fa08c9572da1809ab575691e Mon Sep 17 00:00:00 2001 From: skeller-tv <45237037+skeller-tv@users.noreply.github.com> Date: Thu, 25 May 2023 16:03:01 +0200 Subject: [PATCH 021/110] allow unmanage of Devices, add LastSeen field to managed devices (#17) Add new field "LastSeenAt" to devices fetched via API Add new function "Remove-TeamViewerManagedDeviceManagement" to allow unmanaging of devices --- Build/New-TeamViewerPSPackage.ps1 | 12 +- CHANGELOG.md | 4 +- .../ConvertTo-TeamViewerManagedDevice.ps1 | 4 +- ...move-TeamViewerManagedDeviceManagement.ps1 | 28 +++++ TeamViewerPS/TeamViewerPS.psd1 | 4 +- .../Get-TeamViewerManagedDevice.Tests.ps1 | 5 + ...eamViewerManagedDeviceManagement.Tests.ps1 | 45 +++++++ docs/about_TeamViewerPS.md | 2 + ...emove-TeamViewerManagedDeviceManagement.md | 116 ++++++++++++++++++ 9 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1 create mode 100644 Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 create mode 100644 docs/commands/Remove-TeamViewerManagedDeviceManagement.md diff --git a/Build/New-TeamViewerPSPackage.ps1 b/Build/New-TeamViewerPSPackage.ps1 index a0b8be5..c608dfe 100644 --- a/Build/New-TeamViewerPSPackage.ps1 +++ b/Build/New-TeamViewerPSPackage.ps1 @@ -18,7 +18,7 @@ New-Item -Type Directory "$BuildOutputPath/TeamViewerPS" | Out-Null # Compile all functions into a single psm file $targetFile = "$BuildOutputPath/TeamViewerPS/TeamViewerPS.psm1" -Write-Verbose "Compiling single-file TeamViewer module." +Write-Verbose 'Compiling single-file TeamViewer module.' $ModuleTypes = @(Get-ChildItem -Path "$repoPath/TeamViewerPS/TeamViewerPS.Types.ps1") $PrivateFunctions = @(Get-ChildItem ` -Path "$repoPath/TeamViewerPS/Private/*.ps1" ` @@ -31,10 +31,10 @@ Write-Verbose "Found $($PublicFunctions.Count) public function files." @($ModuleTypes + $PrivateFunctions + $PublicFunctions) | ` Get-Content -Raw | ` ForEach-Object { $_; "`r`n" } | ` - Set-Content -Path $targetFile -Encoding utf8NoBOM + Set-Content -Path $targetFile -Encoding UTF8 # Create help from markdown -Write-Verbose "Building help from Markdown" +Write-Verbose 'Building help from Markdown' New-ExternalHelp ` -Path "$repoPath/docs" ` -OutputPath "$BuildOutputPath/TeamViewerPS/en-US" | ` @@ -45,7 +45,7 @@ New-ExternalHelp ` Out-Null # Create module manifest -Write-Verbose "Creating module manifest" +Write-Verbose 'Creating module manifest' Copy-Item ` -Path "$repoPath/TeamViewerPS/TeamViewerPS.psd1" ` -Destination "$BuildOutputPath/TeamViewerPS/" @@ -58,7 +58,7 @@ Update-Metadata ` -Value $PublicFunctions.BaseName # Copy additional package files -Write-Verbose "Copying additional files into the package" +Write-Verbose 'Copying additional files into the package' Copy-Item ` -Path ` "$repoPath/LICENSE", ` @@ -66,7 +66,7 @@ Copy-Item ` "$repoPath/README.md"` -Destination "$BuildOutputPath/TeamViewerPS/" -Write-Verbose "Listing package files:" +Write-Verbose 'Listing package files:' Push-Location $BuildOutputPath Get-ChildItem -Recurse "$BuildOutputPath/TeamViewerPS" | ` Sort-Object -Property FullName | ` diff --git a/CHANGELOG.md b/CHANGELOG.md index 63438a7..9687455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,16 @@ # Change Log -## 1.x.0 (2023-0x-xx) +## 1.5.0 (2023-05-24) ### Added - Added `Remove-TeamViewerUser` cmdlet to remove user from TeamViewer company. (Thanks @OtterKring) +- Added `Remove-TeamViewerManagedDeviceManagement` to unmanage a device. ### Changed - Extended `Add-TeamViewerManager` to add user group as manager. (Thanks @OtterKring) +- Extended `TeamViewerManagedDevice` to have "LastSeenAt" available for managed devices ## 1.4.0 (2022-04-19) diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerManagedDevice.ps1 b/TeamViewerPS/Private/ConvertTo-TeamViewerManagedDevice.ps1 index fc5b456..d192832 100644 --- a/TeamViewerPS/Private/ConvertTo-TeamViewerManagedDevice.ps1 +++ b/TeamViewerPS/Private/ConvertTo-TeamViewerManagedDevice.ps1 @@ -12,8 +12,8 @@ function ConvertTo-TeamViewerManagedDevice { IsOnline = $InputObject.isOnline } - if ($InputObject.pendingOperation) { - $properties["PendingOperation"] = $InputObject.pendingOperation + if ($InputObject.last_seen) { + $properties['LastSeenAt'] = Get-Date -Date $InputObject.last_seen } if ($InputObject.teamviewerPolicyId) { diff --git a/TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1 b/TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1 new file mode 100644 index 0000000..202c001 --- /dev/null +++ b/TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1 @@ -0,0 +1,28 @@ +function Remove-TeamViewerManagedDeviceManagement { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias('DeviceId')] + [object] + $Device + ) + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($deviceId, 'Remove Management from a device (clears all managers and groups)')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} diff --git a/TeamViewerPS/TeamViewerPS.psd1 b/TeamViewerPS/TeamViewerPS.psd1 index f87c778..f369816 100644 --- a/TeamViewerPS/TeamViewerPS.psd1 +++ b/TeamViewerPS/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '1.4.0' + ModuleVersion = '1.5.0' # Supported PSEditions. # CompatiblePSEditions = @() @@ -54,7 +54,7 @@ # TypesToProcess = @() # Format files (.ps1xml) to be loaded when importing this module. - FormatsToProcess = @('TeamViewerPS.format.ps1xml') + FormatsToProcess = @('TeamViewerPS.format.ps1xml') # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess. # NestedModules = @() diff --git a/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 index 19a00bc..9aa85c9 100644 --- a/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 @@ -97,12 +97,14 @@ Describe 'Get-TeamViewerManagedDevice' { name = 'test device 1' teamviewerId = 12345678 isOnline = $false + last_seen = '2023-02-03T11:14:19Z' }, @{ id = 'bc76c466-50dc-4b1f-963d-9b3a10a40ec6' name = 'test device 2' teamviewerId = 87654321 isOnline = $true + last_seen = '2023-02-03T11:14:19Z' } ) } } @@ -141,12 +143,14 @@ Describe 'Get-TeamViewerManagedDevice' { name = 'test device 1' teamviewerId = 12345678 isOnline = $false + last_seen = '2023-02-03T11:14:19Z' }, @{ id = 'bc76c466-50dc-4b1f-963d-9b3a10a40ec6' name = 'test device 2' teamviewerId = 87654321 isOnline = $true + last_seen = '2023-02-03T11:14:19Z' } ) } } @@ -158,6 +162,7 @@ Describe 'Get-TeamViewerManagedDevice' { name = 'test device 3' teamviewerId = 12345678 isOnline = $false + last_seen = '2023-02-03T11:14:19Z' } ) } } -ParameterFilter { $Body -And $Body['paginationToken'] -eq 'abc' } diff --git a/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 new file mode 100644 index 0000000..10571a2 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 @@ -0,0 +1,45 @@ +BeforeAll { + . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testDeviceId = 'c37e72b8-b78d-467f-923c-6083c13cf82f' + $null = $testDeviceId + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { } +} + +Describe 'Remove-TeamViewerManagedDeviceManagement' { + It 'Should call the correct API endpoint' { + Remove-TeamViewerManagedDeviceManagement -ApiToken $testApiToken -DeviceId $testDeviceId + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/managed/devices/$testDeviceId" -And ` + $Method -eq 'Delete' } + } + + It 'Should accept ManagedDevice objects' { + $testDeviceObj = @{ id = $testDeviceId } | ConvertTo-TeamViewerManagedDevice + Remove-TeamViewerManagedDeviceManagement -ApiToken $testApiToken -Device $testDeviceObj + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/managed/devices/$testDeviceId" -And ` + $Method -eq 'Delete' } + } + + It 'Should accept pipeline input' { + $testDeviceObj = @{ id = $testDeviceId } | ConvertTo-TeamViewerManagedDevice + $testDeviceObj | Remove-TeamViewerManagedDeviceManagement -ApiToken $testApiToken + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/managed/devices/$testDeviceId" -And ` + $Method -eq 'Delete' } + } +} diff --git a/docs/about_TeamViewerPS.md b/docs/about_TeamViewerPS.md index bcb2575..6c8fe9f 100644 --- a/docs/about_TeamViewerPS.md +++ b/docs/about_TeamViewerPS.md @@ -111,6 +111,8 @@ The following functions are available in this category: [`Remove-TeamViewerManagedDevice`](commands/Remove-TeamViewerManagedDevice.md) +[`Remove-TeamViewerManagedDeviceManagement`](commands/Remove-TeamViewerManagedDeviceManagement.md) + [`Remove-TeamViewerManagedGroup`](commands/Remove-TeamViewerManagedGroup.md) [`Remove-TeamViewerManager`](commands/Remove-TeamViewerManager.md) diff --git a/docs/commands/Remove-TeamViewerManagedDeviceManagement.md b/docs/commands/Remove-TeamViewerManagedDeviceManagement.md new file mode 100644 index 0000000..6c2197e --- /dev/null +++ b/docs/commands/Remove-TeamViewerManagedDeviceManagement.md @@ -0,0 +1,116 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerManagedDeviceManagement.md +schema: 2.0.0 +--- + +# Remove-TeamViewerManagedDevice + +## SYNOPSIS + +Removes the management status from a managed device. + +## SYNTAX + +```powershell +Remove-TeamViewerManagedDeviceManagement [-ApiToken] [-Device] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION + +Removes the management status from a managed device. +This makes the device unmanaged removing it from all groups and removing all managers. +The current account needs `ManagerAdministration` manager permissions on the device. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerManagedDeviceManagement -Device 'c0cb303a-8a85-4e54-b657-a4757c791aef' +``` + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -Device + +Object that can be used to identify the managed device. +This can either be the managed device ID (as string or GUID) or a managed device +object that has been received using other module functions. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: DeviceId + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +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 +``` + +### 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.Object + +## OUTPUTS + +## NOTES + +## RELATED LINKS From 66bc8429b21a16a4a5e0c7a1f633e8806cddd608 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Mon, 19 Jun 2023 10:57:40 +0200 Subject: [PATCH 022/110] Add Github issue templates Add Github issue templates for bug, feature and question --- .github/ISSUE_TEMPLATE/bug-report.md | 23 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 20 ++++++++++++++++++++ .github/ISSUE_TEMPLATE/question.md | 14 ++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..d11d3f5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,23 @@ +--- +name: Bug Report +about: Create a bug report +title: "[Bug] " +labels: Bug +assignees: '' + +--- + +**Summary** +Describe clearly and concisely what is not working or is wrong. + +**Expected Behavior** +Descripe what you expected to happen. + +**Setps To Reproduce** +Descript the steps to reproduce the behavior: +1. Configure '...' with value '...' +2. Execute with "..." +3. See error ... + +**Attachments** +If applicable, provide files (e.g. configuration, log files, screenshots) to help explain your problem. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000..ff39052 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,20 @@ +--- +name: Feature Request +about: Create a feature request +title: "[Feature] " +labels: Feature +assignees: ChristianJ-TV + +--- + +**Summary** +Describe clearly and concisely of what the problem is. + +**Expected Solution** +Describe the solution you'd like or what you want to happen. + +**Considerations** +Any alternative solutions or ideas you've considered. + +**Attachments** +If applicable, provide files (e.g. configuration, log files, screenshots) to help explain your idea. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..d9b1b33 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,14 @@ +--- +name: Question +about: Raise a question +title: "[Question] " +labels: Question +assignees: '' + +--- + +**Summary** +Describe clearly and concisely what is your question. + +**Attachments** +If applicable, provide files (e.g. configuration, log files, screenshots) to help explain your question. From 52c39e2ddca04ac69730f2e0bb4d677b9f41fee8 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 28 Jun 2023 19:12:35 +0200 Subject: [PATCH 023/110] Update bug-report.md Fixed typos... --- .github/ISSUE_TEMPLATE/bug-report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index d11d3f5..84f1993 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -11,10 +11,10 @@ assignees: '' Describe clearly and concisely what is not working or is wrong. **Expected Behavior** -Descripe what you expected to happen. +Describe what you expected to happen. **Setps To Reproduce** -Descript the steps to reproduce the behavior: +Describe the steps to reproduce the behavior: 1. Configure '...' with value '...' 2. Execute with "..." 3. See error ... From ef6c65a515bc4f235bdfa0b479f5ba2b5723a47a Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:42:46 +0200 Subject: [PATCH 024/110] Update ci.yml Switch from "required" to "minimum" versions for required Powershell modules --- .github/workflows/ci.yml | 49 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 118688e..cd77c5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,50 +1,49 @@ name: CI +# Controls when the workflow will run on: - workflow_dispatch: + # Triggers the workflow on push or pull request events but only for the master branch push: - branches: [main] + branches: [ main ] pull_request: - branches: [main] + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: jobs: verify: runs-on: ubuntu-latest steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it - uses: actions/checkout@v2 - # Print versions + # Print Powershell version - name: Powershell Environment shell: pwsh run: | $PSVersionTable - - # Run tests - - name: Run Pester + # Run linter + - name: Run linter (via PSScriptAnalyzer) shell: pwsh run: | - $ProgressPreference='SilentlyContinue' - Install-Module Pester -Force -SkipPublisherCheck -Scope CurrentUser ` - -RequiredVersion 5.1.1 -Verbose - Invoke-Pester $env:GITHUB_WORKSPACE -Output Detailed -CI - - # Run linter - - name: Run Script Analyzer + $ProgressPreference = 'SilentlyContinue' + $ErrorActionPreference = 'Stop' + Install-Module -Name PSScriptAnalyzer -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 1.19.1 -Force -Verbose + Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -ReportSummary -EnableExit -ExcludeRule PSReviewUnusedParameter + # Run tests + - name: Run tests (via Pester) shell: pwsh run: | - $ProgressPreference='SilentlyContinue' - $ErrorActionPreference='Stop' - Install-Module PSScriptAnalyzer -Force -SkipPublisherCheck -Scope CurrentUser ` - -RequiredVersion 1.19.1 -Verbose - Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -ReportSummary -EnableExit - - # Try to build the package + $ProgressPreference = 'SilentlyContinue' + Install-Module -Name Pester -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 5.1.1 -Force -Verbose + Invoke-Pester -Path $env:GITHUB_WORKSPACE -Output Detailed -CI + # Build package - name: Package Build shell: pwsh run: | - $ProgressPreference='SilentlyContinue' - $ErrorActionPreference='Stop' - Install-Module platyPS,BuildHelpers -Force -SkipPublisherCheck -Scope CurrentUser + $ProgressPreference = 'SilentlyContinue' + $ErrorActionPreference = 'Stop' + Install-Module -Name platyPS, BuildHelpers -SkipPublisherCheck -Scope CurrentUser -Force & $env:GITHUB_WORKSPACE/Build/New-TeamViewerPSPackage.ps1 -Verbose From 9918cd7e34c9c8e7c1c5d983842e60158d84c790 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:41:44 +0200 Subject: [PATCH 025/110] Update PSScriptAnalyzerSettings.psd1 Add "Information" level --- PSScriptAnalyzerSettings.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 3ddc4d7..8d6610f 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -1,4 +1,4 @@ @{ - Severity = @('Error', 'Warning') + Severity = @('Error', 'Warning', 'Information') ExcludeRules = @('PSUseToExportFieldsInManifest') } From e17a620997cfcab2fedb4731347ba4604f0637c2 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:44:35 +0200 Subject: [PATCH 026/110] Update ci.yml Use general settings for PSScriptAnalyzer --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd77c5e..c5543a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Stop' Install-Module -Name PSScriptAnalyzer -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 1.19.1 -Force -Verbose - Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -ReportSummary -EnableExit -ExcludeRule PSReviewUnusedParameter + Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -Settings (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'PSScriptAnalyzerSettings.psd1') -ReportSummary -EnableExit # Run tests - name: Run tests (via Pester) shell: pwsh From d770c5371a15a17846f1584ed71fc79429c79e08 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Tue, 18 Jul 2023 12:58:06 +0200 Subject: [PATCH 027/110] Fixed Member and User parameter for Add-TeamViewerUserGroupMember and Remove-TeamViewerUserGroupMember --- CHANGELOG.md | 4 ++ .../Public/Add-TeamViewerUserGroupMember.ps1 | 45 +++++++++----- .../Remove-TeamViewerUserGroupMember.ps1 | 58 +++++++++++-------- 3 files changed, 71 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9687455..5595003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.5.1 (2023-07-18) + +- Fixed `-User` parameter of `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` to work for single User ID inputs. + ## 1.5.0 (2023-05-24) ### Added diff --git a/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 b/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 index 1dcabb9..4a122d0 100644 --- a/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 +++ b/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 @@ -7,20 +7,21 @@ function Add-TeamViewerUserGroupMember { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] + [Alias('UserGroupId')] + [Alias('Id')] [object] $UserGroup, [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [int[]] + [object[]] $Member ) Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToAdd = @() + $body = @() $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 function Invoke-TeamViewerRestMethodInternal { @@ -28,23 +29,41 @@ function Add-TeamViewerUserGroupMember { -ApiToken $ApiToken ` -Uri $resourceUri ` -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($membersToAdd | ConvertTo-Json))) ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` -WriteErrorTo $PSCmdlet ` -ErrorAction Stop + Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) } } Process { - # when members are provided as pipline input, each meber is provided as separate statment, - # thus the members should be combined to one array, otherwise we will send several request - if ($PSCmdlet.ShouldProcess($Member, "Add user groups member")) { - $membersToAdd += $Member + # when members are provided as pipeline input, each member is provided as a separate statement, + # thus the members should be combined into one array in order to send a single request. + if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { + if ($Member -notmatch 'u[0-9]+') { + ForEach-Object { + $Member = [int[]]$Member + } + } + else { + ForEach-Object { + $Member = [int[]]$Member.trim('u') + } + } + if ($Member -isnot [array]) { + $membersToAdd = @([UInt32]$Member) + } + else { + $membersToAdd += [UInt32[]]$Member + } + $payload = $membersToAdd -join ', ' + $body = "[$payload]" } - # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToAdd` - # in order to accept more mebers + # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` + # in order to accept more members if ($membersToAdd.Length -eq 100) { Invoke-TeamViewerRestMethodInternal $membersToAdd = @() @@ -52,7 +71,7 @@ function Add-TeamViewerUserGroupMember { } End { - # A request needs to be send if there were less than 100 members + # A request needs to be sent if there were less than 100 members if ($membersToAdd.Length -gt 0) { Invoke-TeamViewerRestMethodInternal } diff --git a/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 b/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 index a65c2cc..b75e862 100644 --- a/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 +++ b/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 @@ -1,5 +1,5 @@ function Remove-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName="ByUserGroupMemberId")] + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] param( [Parameter(Mandatory = $true)] [securestring] @@ -7,21 +7,21 @@ function Remove-TeamViewerUserGroupMember { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] + [Alias('UserGroupId')] + [Alias('Id')] [object] $UserGroup, - [Parameter(Mandatory = $true, ParameterSetName = "ByUserId", ValueFromPipeline = $true)] + [Parameter(Mandatory = $true, ParameterSetName = 'ByUserId', ValueFromPipeline = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] + [Alias('UserId')] [object[]] $User, - [Parameter(Mandatory = $true, ParameterSetName = "ByUserGroupMemberId", ValueFromPipeline = $true)] + [Parameter(Mandatory = $true, ParameterSetName = 'ByUserGroupMemberId', ValueFromPipeline = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] - [Alias("UserGroupMemberId")] - [Alias("MemberId")] + [Alias('UserGroupMemberId')] + [Alias('MemberId')] [object[]] $UserGroupMember ) @@ -33,13 +33,13 @@ function Remove-TeamViewerUserGroupMember { $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 $null = $User $null = $UserGroupMember - function Invoke-TeamViewerRestMethodForMember { + function Invoke-TeamViewerRestMethodInternal { Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` -Method Delete ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($membersToRemove | ConvertTo-Json))) ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` -WriteErrorTo $PSCmdlet ` -ErrorAction Stop | ` Out-Null @@ -47,18 +47,22 @@ function Remove-TeamViewerUserGroupMember { function Get-Target { switch ($PsCmdlet.ParameterSetName) { - 'ByUserId' { return $User.ToString() } - Default { return $UserGroupMember.ToString() } + 'ByUserId' { + return $User.ToString() + } + Default { + return $UserGroupMember.ToString() + } } } function Get-MemberId { switch ($PsCmdlet.ParameterSetName) { 'ByUserId' { - $UserId = $User | Resolve-TeamViewerUserId + $UserId = $User $UserId.TrimStart('u') } - 'ByUserGroupMemberId'{ + 'ByUserGroupMemberId' { return $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId } } @@ -66,16 +70,24 @@ function Remove-TeamViewerUserGroupMember { } Process { - # when members are provided as pipline input, each meber is provided as separate statment, - # thus the members should be combined to one array, otherwise we will send several request - if ($PSCmdlet.ShouldProcess((Get-Target), "Remove user group member")) { - $membersToRemove += Get-MemberId + # when members are provided as pipeline input, each member is provided as separate statement, + # thus the members should be combined to one array in order to send a single request + if ($PSCmdlet.ShouldProcess((Get-Target), 'Remove user group member')) { + + if (Get-MemberId -isnot [array]) { + $membersToRemove += @(Get-MemberId) + } + else { + $membersToRemove += Get-MemberId + } + $payload = $membersToRemove -join ', ' + $body = "[$payload]" } - # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToAdd` - # in order to accept more mebers + # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` + # in order to accept more members if ($membersToRemove.Length -eq 100) { - Invoke-TeamViewerRestMethodForMember + Invoke-TeamViewerRestMethodInternal $membersToRemove = @() } } @@ -83,7 +95,7 @@ function Remove-TeamViewerUserGroupMember { End { # A request needs to be send if there were less than 100 members if ($membersToRemove.Length -gt 0) { - Invoke-TeamViewerRestMethodForMember + Invoke-TeamViewerRestMethodInternal } } } From 0e3a81298fd758d2751d704fe7755d97ddba5659 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Wed, 19 Jul 2023 13:14:02 +0200 Subject: [PATCH 028/110] Remove-TeamViewerUserGroupMember modified to work with two user id formats under same param, UserGroupMember alias added to Add-TeamViewerUserGroupMember --- .../Resolve-TeamViewerUserGroupMemberId.ps1 | 6 +- .../Public/Add-TeamViewerUserGroupMember.ps1 | 7 +- .../Remove-TeamViewerUserGroupMember.ps1 | 46 ++++++------- ...Remove-TeamViewerUserGroupMember.Tests.ps1 | 67 ++++--------------- .../Remove-TeamViewerUserGroupMember.md | 4 +- 5 files changed, 44 insertions(+), 86 deletions(-) diff --git a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 b/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 index d983e59..981db01 100644 --- a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 +++ b/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 @@ -8,14 +8,14 @@ function Resolve-TeamViewerUserGroupMemberMemberId { if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { return $UserGroupMember.AccountId } - elseif ($UserGroupMember -is [string]) { - return [int]$UserGroupMember + elseif ($UserGroupMember -match 'u[0-9]+') { + return $UserGroupMember } elseif ($UserGroupMember -is [int]) { return $UserGroupMember } else { - throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember], [int] or [string]." + throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." } } } diff --git a/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 b/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 index 4a122d0..9d5d576 100644 --- a/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 +++ b/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 @@ -14,13 +14,18 @@ function Add-TeamViewerUserGroupMember { [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [object[]] + [Alias('UserGroupMemberId')] + [Alias('UserGroupMember')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] $Member ) Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToAdd = @() $body = @() $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 b/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 index b75e862..24cc8bb 100644 --- a/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 +++ b/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 @@ -12,16 +12,13 @@ function Remove-TeamViewerUserGroupMember { [object] $UserGroup, - [Parameter(Mandatory = $true, ParameterSetName = 'ByUserId', ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias('UserId')] - [object[]] - $User, - [Parameter(Mandatory = $true, ParameterSetName = 'ByUserGroupMemberId', ValueFromPipeline = $true)] + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] [Alias('UserGroupMemberId')] [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] [object[]] $UserGroupMember ) @@ -31,7 +28,6 @@ function Remove-TeamViewerUserGroupMember { $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" $membersToRemove = @() $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $User $null = $UserGroupMember function Invoke-TeamViewerRestMethodInternal { Invoke-TeamViewerRestMethod ` @@ -45,25 +41,24 @@ function Remove-TeamViewerUserGroupMember { Out-Null } - function Get-Target { - switch ($PsCmdlet.ParameterSetName) { - 'ByUserId' { - return $User.ToString() - } - Default { - return $UserGroupMember.ToString() - } - } - } - function Get-MemberId { - switch ($PsCmdlet.ParameterSetName) { - 'ByUserId' { - $UserId = $User - $UserId.TrimStart('u') + switch ($UserGroupMember) { + { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { + $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId + return $UserGroupMember } - 'ByUserGroupMemberId' { - return $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId + Default { + if ($UserGroupMember -notmatch 'u[0-9]+') { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember + } + } + else { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember.trim('u') + } + } + return $UserGroupMember } } } @@ -72,8 +67,7 @@ function Remove-TeamViewerUserGroupMember { Process { # when members are provided as pipeline input, each member is provided as separate statement, # thus the members should be combined to one array in order to send a single request - if ($PSCmdlet.ShouldProcess((Get-Target), 'Remove user group member')) { - + if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { if (Get-MemberId -isnot [array]) { $membersToRemove += @(Get-MemberId) } diff --git a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 index b3baa3b..dfee1da 100644 --- a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 @@ -8,17 +8,15 @@ BeforeAll { $null = $testApiToken $testMembers = @(123, 456, 789) $testUserGroupMembers = @( - @{AccountId = $testMembers[0]; Name = 'test account 1' } | ConvertTo-TeamViewerUserGroupMember - @{AccountId = $testMembers[1]; Name = 'test account 2' } | ConvertTo-TeamViewerUserGroupMember - @{AccountId = $testMembers[2]; Name = 'test account 3' } | ConvertTo-TeamViewerUserGroupMember + @{AccountId = $testMembers[0]; Name = 'test account 1' } + @{AccountId = $testMembers[1]; Name = 'test account 2' } + @{AccountId = $testMembers[2]; Name = 'test account 3' } ) $null = $testUserGroupMembers - $testUsers = @('u123', 'u456', 'u789') - $null = $testUsers $testUserGroupId = 1001 $null = $testUserGroupId - $testUserGroupMemberId = $testMembers[0] - $null = $testUserGroupMemberId + $testUserGroupMember = @($testMembers[0], $testMembers[1], $testMembers[2]) + $null = $testUserGroupMember Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} @@ -33,11 +31,11 @@ Describe 'Remove-TeamViewerUserGroupMember' { Remove-TeamViewerUserGroupMember ` -ApiToken $testApiToken ` -UserGroup $testUserGroupId ` - -UserGroupMember $testMembers + -UserGroupMember $testUserGroupMember Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` - $Method -eq 'Delete' } + $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` + $Method -eq 'Delete' } } It 'Should handle domain object as input' { @@ -45,18 +43,18 @@ Describe 'Remove-TeamViewerUserGroupMember' { Remove-TeamViewerUserGroupMember ` -ApiToken $testApiToken ` -UserGroup $testUserGroup ` - -UserGroupMember $testMembers + -UserGroupMember $testUserGroupMember Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` - $Method -eq 'Delete' } + $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` + $Method -eq 'Delete' } } It 'Should add the given members to the user group' { Remove-TeamViewerUserGroupMember ` -ApiToken $testApiToken ` -UserGroup $testUserGroupId ` - -UserGroupMember $testMembers + -UserGroupMember $testUserGroupMember $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json $body | Should -HaveCount 3 @@ -78,7 +76,7 @@ Describe 'Remove-TeamViewerUserGroupMember' { } It 'Should accept pipeline input as obj' { - $testUserGroupMembers | Remove-TeamViewerUserGroupMember ` + $testUserGroupMember | Remove-TeamViewerUserGroupMember ` -ApiToken $testApiToken ` -UserGroup $testUserGroupId $mockArgs.Body | Should -Not -BeNullOrEmpty @@ -98,43 +96,4 @@ Describe 'Remove-TeamViewerUserGroupMember' { $body | Should -HaveCount 2 } } - - Context 'Should remove members ByUserId' { - - It 'Should call the correct API endpoint' { - Remove-TeamViewerUserGroupMember ` - -ApiToken $testApiToken ` - -UserGroup $testUserGroupId ` - -User "u$testUserGroupMemberId" - - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` - $Method -eq 'Delete' } - } - - It 'Should handle domain object as input' { - $testUserGroup = @{Id = $testUserGroupId; Name = 'test user group' } | ConvertTo-TeamViewerUserGroup - Remove-TeamViewerUserGroupMember ` - -ApiToken $testApiToken ` - -UserGroup $testUserGroup ` - -User $testUsers - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` - $Method -eq 'Delete' } - } - - It 'Should accept pipeline input as obj' { - $testUsers | Remove-TeamViewerUserGroupMember ` - -ApiToken $testApiToken ` - -UserGroup $testUserGroupId - $mockArgs.Body | Should -Not -BeNullOrEmpty - $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json - $body | Should -HaveCount 3 - $body | Should -Contain $testMembers[0] - $body | Should -Contain $testMembers[1] - $body | Should -Contain $testMembers[2] - } - } } diff --git a/docs/commands/Remove-TeamViewerUserGroupMember.md b/docs/commands/Remove-TeamViewerUserGroupMember.md index 687a05d..6c9162d 100644 --- a/docs/commands/Remove-TeamViewerUserGroupMember.md +++ b/docs/commands/Remove-TeamViewerUserGroupMember.md @@ -61,10 +61,10 @@ Removes the users `u123`, `u456`, `u789` from the group with id `1001`. ### Example 4 ```powershell -PS /> @('u123', 'u456', 'u789') | Remove-TeamViewerUserGroupMember -UserGroup 1001 +PS /> Get-TeamViewerUserGroupMember -UserGroup 1001 | Remove-TeamViewerUserGroupMember -UserGroup 1001 ``` -Removes the users `u123`, `u456`, `u789` from the group with id `1001`. +Removes all the users from the group with id `1001`. Ids are passed as pipeline input. ## PARAMETERS From 67b6ea00786e0ae5a6d83c53bf466e20008455c0 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Wed, 19 Jul 2023 15:14:31 +0200 Subject: [PATCH 029/110] Updated Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5595003..f53495d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.5.1 (2023-07-18) -- Fixed `-User` parameter of `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` to work for single User ID inputs. +- Improved `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` ## 1.5.0 (2023-05-24) From a0442bf08dc629171e3a086ca0e34d15d9645ac0 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Thu, 20 Jul 2023 10:06:14 +0200 Subject: [PATCH 030/110] Tests for single user ID input added --- .../Resolve-TeamViewerUserGroupMemberId.ps1 | 3 +++ TeamViewerPS/TeamViewerPS.psd1 | 2 +- .../Add-TeamViewerUserGroupMember.Tests.ps1 | 21 +++++++++++++++---- ...Remove-TeamViewerUserGroupMember.Tests.ps1 | 15 ++++++++++++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 b/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 index 981db01..4d75627 100644 --- a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 +++ b/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 @@ -11,6 +11,9 @@ function Resolve-TeamViewerUserGroupMemberMemberId { elseif ($UserGroupMember -match 'u[0-9]+') { return $UserGroupMember } + elseif ($UserGroupMember -is [string]) { + return [int]$UserGroupMember + } elseif ($UserGroupMember -is [int]) { return $UserGroupMember } diff --git a/TeamViewerPS/TeamViewerPS.psd1 b/TeamViewerPS/TeamViewerPS.psd1 index f369816..97eeb1d 100644 --- a/TeamViewerPS/TeamViewerPS.psd1 +++ b/TeamViewerPS/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '1.5.0' + ModuleVersion = '1.5.1' # Supported PSEditions. # CompatiblePSEditions = @() diff --git a/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 index b50f62b..9b6e02f 100644 --- a/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 @@ -8,6 +8,8 @@ BeforeAll { $null = $testApiToken $testMembers = @(123, 456, 789) $null = $testMembers + $testMemberWithU = @('u101') + $null = $testMemberWithU $testUserGroupId = 1001 $null = $testUserGroupId @@ -24,8 +26,8 @@ Describe 'Add-TeamViewerUserGroupMember' { -Member $testMembers Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` - $Method -eq 'Post' } + $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` + $Method -eq 'Post' } } It 'Should handle domain object as input' { @@ -36,8 +38,19 @@ Describe 'Add-TeamViewerUserGroupMember' { -Member $testMembers Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` - $Method -eq 'Post' } + $Uri -eq "//unit.test/usergroups/$testUserGroupId/members" -And ` + $Method -eq 'Post' } + } + + It 'Should add a single member to the user group with format u[0-9]+' { + Add-TeamViewerUserGroupMember ` + -ApiToken $testApiToken ` + -UserGroup $testUserGroupId ` + -Member $testMemberWithU + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body | Should -HaveCount 1 + $body | Should -Contain $testMemberWithU.trim('u') } It 'Should add the given members to the user group' { diff --git a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 index dfee1da..dfe1add 100644 --- a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 @@ -7,6 +7,8 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken $testMembers = @(123, 456, 789) + $testMemberId = @('u101') + $null = $testMemberId $testUserGroupMembers = @( @{AccountId = $testMembers[0]; Name = 'test account 1' } @{AccountId = $testMembers[1]; Name = 'test account 2' } @@ -25,7 +27,7 @@ BeforeAll { Describe 'Remove-TeamViewerUserGroupMember' { - Context 'Should bulk remove members ByUserGroupMemberId' { + Context 'Should remove members ByUserGroupMember' { It 'Should call the correct API endpoint' { Remove-TeamViewerUserGroupMember ` @@ -38,6 +40,17 @@ Describe 'Remove-TeamViewerUserGroupMember' { $Method -eq 'Delete' } } + It 'Should remove a single user from the user group' { + Remove-TeamViewerUserGroupMember ` + -ApiToken $testApiToken ` + -UserGroup $testUserGroupId ` + -UserGroupMember $testMemberId + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body | Should -HaveCount 1 + $body | Should -Contain $testMemberId.trim('u') + } + It 'Should handle domain object as input' { $testUserGroup = @{Id = $testUserGroupId; Name = 'test user group' } | ConvertTo-TeamViewerUserGroup Remove-TeamViewerUserGroupMember ` From f9d7b50d9db6993f5e286706b4a42314a1186f1f Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:24:43 +0200 Subject: [PATCH 031/110] Update ci.yml Changes checkout version to v3 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5543a7..deeba7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: steps: # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Print Powershell version - name: Powershell Environment From 0d5651c0e4f6b705601c01d61504e4c3b199c593 Mon Sep 17 00:00:00 2001 From: Alexandros Alexiou Date: Wed, 13 Sep 2023 16:26:29 +0300 Subject: [PATCH 032/110] Add inherit from group policy functionality and remove policy from device --- ...move-TeamViewerPolicyFromManagedDevice.ps1 | 39 +++++ .../Public/Set-TeamViewerManagedDevice.ps1 | 14 ++ TeamViewerPS/TeamViewerPS.Types.ps1 | 6 + ...eamViewerPolicyFromManagedDevice.Tests.ps1 | 55 ++++++ .../Set-TeamViewerManagedDevice.Tests.ps1 | 23 +++ ...emove-TeamViewerPolicyFromManagedDevice.md | 157 ++++++++++++++++++ docs/commands/Set-TeamViewerManagedDevice.md | 30 +++- 7 files changed, 322 insertions(+), 2 deletions(-) create mode 100644 TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 create mode 100644 Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 create mode 100644 docs/commands/Remove-TeamViewerPolicyFromManagedDevice.md diff --git a/TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 b/TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 new file mode 100644 index 0000000..61d7fa2 --- /dev/null +++ b/TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 @@ -0,0 +1,39 @@ +function Remove-TeamviewerPolicyFromManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [PolicyType] + $PolicyType + ) + Begin { + $body = @{ + 'policy_type' = [int]$PolicyType + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/policy/remove" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} diff --git a/TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1 b/TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1 index ec99fef..62d415f 100644 --- a/TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1 +++ b/TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1 @@ -20,6 +20,11 @@ function Set-TeamViewerManagedDevice { [object] $Policy, + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("ManagedGroupId")] + [object] + $ManagedGroup, + [switch] $RemovePolicy ) @@ -35,6 +40,9 @@ function Set-TeamViewerManagedDevice { elseif ($RemovePolicy) { $body['teamviewerPolicyId'] = "" } + elseif ($ManagedGroup) { + $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId + } if ($Policy -And $RemovePolicy) { $PSCmdlet.ThrowTerminatingError( @@ -42,6 +50,12 @@ function Set-TeamViewerManagedDevice { ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } + if (($Policy -or $RemovePolicy) -And $ManagedGroup) { + $PSCmdlet.ThrowTerminatingError( + ("The combination of parameters -Policy, -PolicyRemove and -ManagedGroup is not allowed." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($body.Count -eq 0) { $PSCmdlet.ThrowTerminatingError( ("The given input does not change the managed device." | ` diff --git a/TeamViewerPS/TeamViewerPS.Types.ps1 b/TeamViewerPS/TeamViewerPS.Types.ps1 index cabf757..b1a10b0 100644 --- a/TeamViewerPS/TeamViewerPS.Types.ps1 +++ b/TeamViewerPS/TeamViewerPS.Types.ps1 @@ -3,3 +3,9 @@ enum TeamViewerConnectionReportSessionType { RemoteSupportActive = 2 RemoteSupportActiveSdk = 3 } + +enum PolicyType { + TeamViewer = 1 + Monitoring = 4 + PatchManagement = 5 +} diff --git a/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 new file mode 100644 index 0000000..4f87cdb --- /dev/null +++ b/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 @@ -0,0 +1,55 @@ +BeforeAll { + . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1" + . "$PSScriptRoot/../../TeamViewerPS/TeamViewerPS.Types.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testDeviceId = '9e5617cb-2b20-4da2-bca4-c1bda85b29ab' + $null = $testDeviceId + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body } +} + +Describe 'Remove-TeamViewerPolicyFromManagedDevice' { + + It 'Should call the correct API endpoint to remove a policy from the managed device' { + Remove-TeamViewerPolicyFromManagedDevice -ApiToken $testApiToken -Device $testDeviceId -PolicyType TeamViewer + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/managed/devices/$testDeviceId/policy/remove" -And ` + $Method -eq 'Put' } + } + + It 'should remove teamviewer policy from managed device' { + Remove-TeamViewerPolicyFromManagedDevice -apitoken $testapitoken -device $testdeviceid -Policytype TeamViewer + $mockargs.body | Should -Not -BeNullOrEmpty + $body = [system.text.encoding]::utf8.getstring($mockargs.body) | ConvertFrom-Json + $body.policy_type | Should -Be 1 + } + + It 'should remove monitoring policy from managed device' { + Remove-TeamViewerPolicyFromManagedDevice -apitoken $testapitoken -device $testdeviceid -PolicyType Monitoring + $mockargs.body | Should -Not -BeNullOrEmpty + $body = [system.text.encoding]::utf8.getstring($mockargs.body) | ConvertFrom-Json + $body.policy_type | Should -Be 4 + } + + It 'should remove patch management policy from managed device' { + Remove-TeamViewerPolicyFromManagedDevice -apitoken $testapitoken -device $testdeviceid -PolicyType PatchManagement + $mockargs.body | Should -Not -BeNullOrEmpty + $body = [system.text.encoding]::utf8.getstring($mockargs.body) | ConvertFrom-Json + $body.policy_type | Should -Be 5 + } + + It 'Should throw an error when called with invalid policy type' { + { Remove-TeamViewerPolicyFromManagedDevice ` + -ApiToken $testApiToken ` + -Device $testDeviceId -PolicyType 2 } | Should -Throw + } +} + diff --git a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 index 870e536..3936d3a 100644 --- a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 @@ -45,6 +45,13 @@ Describe 'Set-TeamViewerManagedDevice' { $body.teamviewerPolicyId | Should -Be '' } + It 'Should update the managed device policy to the managed group' { + Set-TeamViewerManagedDevice -ApiToken $testApiToken -Device $testDeviceId -ManagedGroup 'e579cfeb-0b29-4d91-9e81-2d9507f53ff8' + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.managedGroupId | Should -Be 'e579cfeb-0b29-4d91-9e81-2d9507f53ff8' + } + It 'Should not be possible to set and remove the policy at the same time' { { Set-TeamViewerManagedDevice ` -ApiToken $testApiToken ` @@ -53,6 +60,22 @@ Describe 'Set-TeamViewerManagedDevice' { -RemovePolicy } | Should -Throw } + It 'Should not be possible to inherit and set a policy at the same time' { + { Set-TeamViewerManagedDevice ` + -ApiToken $testApiToken ` + -Device $testDeviceId ` + -Policy '2871c013-3040-4969-9ba4-ce970f4375e8' ` + -ManagedGroup '6808db5b-f3c1-4e42-8168-3ac96f5d456e' } | Should -Throw + } + + It 'Should not be possible to inherit and remove a policy at the same time' { + { Set-TeamViewerManagedDevice ` + -ApiToken $testApiToken ` + -Device $testDeviceId ` + -ManagedGroup '2871c013-3040-4969-9ba4-ce970f4375e8' ` + -RemovePolicy } | Should -Throw + } + It 'Should not be possible to use "none" or "inherit" as values for policy' { { Set-TeamViewerManagedDevice ` -ApiToken $testApiToken ` diff --git a/docs/commands/Remove-TeamViewerPolicyFromManagedDevice.md b/docs/commands/Remove-TeamViewerPolicyFromManagedDevice.md new file mode 100644 index 0000000..ecafb2f --- /dev/null +++ b/docs/commands/Remove-TeamViewerPolicyFromManagedDevice.md @@ -0,0 +1,157 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: [Link to Online Documentation] +schema: 2.0.0 +--- + +# Remove-TeamViewerPolicyFromManagedDevice + +## SYNOPSIS + +Remove a policy from a managed device based on type. + +Valid Types are: + +- TeamViewer +- Monitoring +- PatchManagement + +## SYNTAX + +```powershell +Remove-TeamViewerPolicyFromManagedDevice -ApiToken -Device -PolicyType [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Remove a specified policy from a managed device. + +## EXAMPLES + +### Example 1 + +Remove TeamViewer policy from device + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedDevice -Device 'd8773208-a685-4323-9de5-7f86951f8c30' -PolicyType 1 +``` + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedDevice -Device 'd8773208-a685-4323-9de5-7f86951f8c30' -PolicyType TeamViewer +``` + +### Example 2 + +Remove Monitoring policy from device + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedDevice -Device '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType 4 +``` + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedDevice -Device '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType Monitoring +``` + +### Example 3 + +Remove PatchManagement policy from device + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedDevice -Device '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType 5 +``` + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedDevice -Device '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType PatchManagement +``` + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Device + +The managed device from which you want to remove the policy. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: DeviceId +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -PolicyType + +The type of policy to remove from the managed device. + +```yaml +Type: PolicyType (Enum) +Parameter Sets: (All) +Aliases: +Required: True +Position: 2 +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 +``` + +### -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 +``` + +### 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.Object + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Set-TeamViewerManagedDevice.md b/docs/commands/Set-TeamViewerManagedDevice.md index 4599997..1cc2bbb 100644 --- a/docs/commands/Set-TeamViewerManagedDevice.md +++ b/docs/commands/Set-TeamViewerManagedDevice.md @@ -15,7 +15,7 @@ Change properties of a TeamViewer managed device. ```powershell Set-TeamViewerManagedDevice [-ApiToken] [-Device] [[-Name] ] - [[-Policy] ] [-RemovePolicy] [-WhatIf] [-Confirm] [] + [[-Policy] ] [-RemovePolicy] [[-ManagedGroup] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -53,7 +53,15 @@ Sets the policy of the device. PS /> Set-TeamViewerManagedDevice -Device '33a2e2e1-27ef-43e2-a175-f97ee0344033' -RemovePolicy ``` -Removes the policy from the managed device. +Removes the TeamViewer policy of the device. + +### Example 3 + +```powershell +PS /> Set-TeamViewerManagedDevice -Device '33a2e2e1-27ef-43e2-a175-f97ee0344033' -ManagedGroup '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' +``` + +Inherit the TeamViewer policy from a managed group to the device (the device has to be part of the managed group specified). ## PARAMETERS @@ -161,6 +169,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -ManagedGroup + +Object that can be used to identify the managed group. +This can either be the managed group ID (as string or GUID) or a managed group +object that has been received using other module functions. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: ManagedGroupId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + ### -WhatIf Shows what would happen if the cmdlet runs. From 38aec5cea3143e64bbff6e131e75e7f3266a7bc6 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Tue, 19 Sep 2023 09:43:48 +0200 Subject: [PATCH 033/110] Initial Commit --- .github/workflows/ci.yml | 80 ++-- .github/workflows/powershell-analysis.yml | 2 +- .github/workflows/publish_production.yml | 6 +- .github/workflows/publish_testing.yml | 6 +- .gitignore | 2 +- .spelling => .vscode/.spelling | 0 .vscode/tasks.json | 2 +- ...eamViewerPSPackage.ps1 => New-Package.ps1} | 36 +- CHANGELOG.md | 21 + LICENSE => LICENSE.md | 0 Linters/PSScriptAnalyzer.psd1 | 4 + PSScriptAnalyzerSettings.psd1 | 4 - TeamViewerPS/Private/Get-TeamViewerApiUri.ps1 | 3 - .../Public/Test-TeamViewerInstallation.ps1 | 18 - .../Public/Add-TeamViewerAssignment.Tests.ps1 | 68 ++++ .../Add-TeamViewerCustomization.Tests.ps1 | 79 ++++ .../Add-TeamViewerManagedDevice.Tests.ps1 | 4 +- Tests/Public/Add-TeamViewerManager.Tests.ps1 | 4 +- .../Add-TeamViewerRoleToAccount.Tests.ps1 | 61 +++ .../Add-TeamViewerRoleToUserGroup.Tests.ps1 | 39 ++ .../Add-TeamViewerSsoExclusion.Tests.ps1 | 4 +- .../Add-TeamViewerUserGroupMember.Tests.ps1 | 4 +- Tests/Public/Connect-TeamViewerApi.Tests.ps1 | 6 +- .../Public/Disconnect-TeamViewerApi.Tests.ps1 | 2 +- ...port-TeamViewerSystemInformation.Tests.ps1 | 55 +++ Tests/Public/Get-TeamViewerAccount.Tests.ps1 | 4 +- .../Get-TeamViewerConnectionReport.Tests.ps1 | 13 +- Tests/Public/Get-TeamViewerContact.Tests.ps1 | 4 +- .../Get-TeamViewerCustomModuleId.Tests.ps1 | 45 +++ Tests/Public/Get-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerEventLog.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerGroup.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerId.Tests.ps1 | 6 +- ...-TeamViewerInstallationDirectory.Tests.ps1 | 60 +++ .../Get-TeamViewerLogFilePath.Tests.ps1 | 38 ++ .../Get-TeamViewerManagedDevice.Tests.ps1 | 4 +- .../Get-TeamViewerManagedGroup.Tests.ps1 | 4 +- .../Get-TeamViewerManagementId.Tests.ps1 | 6 +- Tests/Public/Get-TeamViewerManager.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerPolicy.Tests.ps1 | 4 +- ...eamViewerRoleAssignmentToAccount.Tests.ps1 | 38 ++ ...mViewerRoleAssignmentToUserGroup.Tests.ps1 | 38 ++ Tests/Public/Get-TeamViewerService.Tests.ps1 | 4 +- .../Public/Get-TeamViewerSsoDomain.Tests.ps1 | 4 +- .../Get-TeamViewerSsoExclusion.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerUser.Tests.ps1 | 4 +- .../Public/Get-TeamViewerUserGroup.Tests.ps1 | 4 +- .../Get-TeamViewerUserGroupMember.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerUserRole.Tests.ps1 | 70 ++++ Tests/Public/Get-TeamViewerVersion.Tests.ps1 | 6 +- Tests/Public/Invoke-TeamViewerPing.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerContact.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerGroup.Tests.ps1 | 4 +- .../New-TeamViewerManagedGroup.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerPolicy.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerUser.Tests.ps1 | 4 +- .../Public/New-TeamViewerUserGroup.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerUserRole.tests.ps1 | 63 +++ .../Public/Publish-TeamViewerGroup.Tests.ps1 | 4 +- .../Remove-TeamViewerAssignment.Tests.ps1 | 49 +++ .../Public/Remove-TeamViewerContact.Tests.ps1 | 4 +- .../Remove-TeamViewerCustomization.Tests.ps1 | 51 +++ .../Public/Remove-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/Remove-TeamViewerGroup.Tests.ps1 | 4 +- .../Remove-TeamViewerManagedDevice.Tests.ps1 | 4 +- ...eamViewerManagedDeviceManagement.Tests.ps1 | 4 +- .../Remove-TeamViewerManagedGroup.Tests.ps1 | 4 +- .../Public/Remove-TeamViewerManager.Tests.ps1 | 4 +- .../Public/Remove-TeamViewerPSProxy.Tests.ps1 | 28 ++ .../Public/Remove-TeamViewerPolicy.Tests.ps1 | 4 +- ...eamViewerPolicyFromManagedDevice.Tests.ps1 | 7 +- ...Remove-TeamViewerRoleFromAccount.Tests.ps1 | 60 +++ ...move-TeamViewerRoleFromUserGroup.Tests.ps1 | 41 ++ .../Remove-TeamViewerSsoExclusion.Tests.ps1 | 4 +- Tests/Public/Remove-TeamViewerUser.Tests.ps1 | 4 +- .../Remove-TeamViewerUserGroup.Tests.ps1 | 4 +- ...Remove-TeamViewerUserGroupMember.Tests.ps1 | 6 +- .../Remove-TeamViewerUserRole.Tests.ps1 | 37 ++ .../Restart-TeamViewerService.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerAccount.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerGroup.Tests.ps1 | 4 +- .../Set-TeamViewerManagedDevice.Tests.ps1 | 4 +- .../Set-TeamViewerManagedGroup.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerManager.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 | 50 +++ Tests/Public/Set-TeamViewerPolicy.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerUser.Tests.ps1 | 4 +- .../Public/Set-TeamViewerUserGroup.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerUserRole.Tests.ps1 | 73 ++++ .../Public/Start-TeamViewerService.Tests.ps1 | 4 +- Tests/Public/Stop-TeamViewerService.Tests.ps1 | 4 +- .../Test-TeamViewerConnectivity.Tests.ps1 | 6 +- .../Test-TeamViewerInstallation.Tests.ps1 | 57 +-- .../Unpublish-TeamViewerGroup.Tests.ps1 | 4 +- docs/Cmdlets/Private/Add-Registry.ps1 | 40 ++ .../Cmdlets}/Private/ConvertTo-DateTime.ps1 | 0 .../Private/ConvertTo-ErrorRecord.ps1 | 0 .../Private/ConvertTo-TeamViewerAccount.ps1 | 0 .../ConvertTo-TeamViewerAuditEvent.ps1 | 0 .../ConvertTo-TeamViewerConnectionReport.ps1 | 0 .../Private/ConvertTo-TeamViewerContact.ps1 | 0 .../Private/ConvertTo-TeamViewerDevice.ps1 | 0 .../Private/ConvertTo-TeamViewerGroup.ps1 | 0 .../ConvertTo-TeamViewerGroupShare.ps1 | 0 .../ConvertTo-TeamViewerManagedDevice.ps1 | 0 .../ConvertTo-TeamViewerManagedGroup.ps1 | 0 .../Private/ConvertTo-TeamViewerManager.ps1 | 0 .../Private/ConvertTo-TeamViewerPolicy.ps1 | 0 .../Private/ConvertTo-TeamViewerRestError.ps1 | 0 .../ConvertTo-TeamViewerRoleAssignedUser.ps1 | 13 + ...vertTo-TeamViewerRoleAssignedUserGroup.ps1 | 13 + .../Private/ConvertTo-TeamViewerSsoDomain.ps1 | 0 .../Private/ConvertTo-TeamViewerUser.ps1 | 0 .../Private/ConvertTo-TeamViewerUserGroup.ps1 | 32 +- .../ConvertTo-TeamViewerUserGroupMember.ps1 | 32 +- .../Private/ConvertTo-TeamViewerUserRole.ps1 | 25 ++ docs/Cmdlets/Private/Get-ClientId.ps1 | 12 + docs/Cmdlets/Private/Get-HostFile.ps1 | 15 + .../Cmdlets/Private/Get-InstalledSoftware.ps1 | 38 ++ docs/Cmdlets/Private/Get-IpConfig.ps1 | 16 + docs/Cmdlets/Private/Get-MSInfo32.ps1 | 17 + docs/Cmdlets/Private/Get-NSLookUpData.ps1 | 50 +++ .../Cmdlets}/Private/Get-OperatingSystem.ps1 | 0 docs/Cmdlets/Private/Get-RegistryPath.ps1 | 47 +++ docs/Cmdlets/Private/Get-RouteTable.ps1 | 24 ++ docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 | 35 ++ .../Private/Get-TSCSearchDirectory.ps1 | 14 + docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 | 22 ++ .../Get-TeamViewerLinuxGlobalConfig.ps1 | 7 +- .../Private/Get-TeamViewerRegKeyPath.ps1 | 0 .../Private/Get-TeamViewerServiceName.ps1 | 0 .../Get-TypeAndValueOfRegistryValue.ps1 | 39 ++ .../Private/Invoke-ExternalCommand.ps1 | 0 .../Private/Invoke-TeamViewerRestMethod.ps1 | 24 +- .../Private/Resolve-AssignmentErrorCode.ps1 | 38 ++ .../Resolve-CustomizationErrorCode.ps1 | 33 ++ .../Private/Resolve-TeamViewerContactId.ps1 | 0 .../Private/Resolve-TeamViewerDeviceId.ps1 | 0 .../Private/Resolve-TeamViewerGroupId.ps1 | 0 .../Private/Resolve-TeamViewerLanguage.ps1 | 0 .../Resolve-TeamViewerManagedDeviceId.ps1 | 0 .../Resolve-TeamViewerManagedGroupId.ps1 | 0 .../Private/Resolve-TeamViewerManagerId.ps1 | 0 .../Private/Resolve-TeamViewerPolicyId.ps1 | 0 .../Private/Resolve-TeamViewerSsoDomainId.ps1 | 0 .../Private/Resolve-TeamViewerUserEmail.ps1 | 0 .../Private/Resolve-TeamViewerUserGroupId.ps1 | 42 +- .../Resolve-TeamViewerUserGroupMemberId.ps1 | 48 +-- .../Private/Resolve-TeamViewerUserId.ps1 | 0 .../Private/Resolve-TeamViewerUserRoleId.ps1 | 19 + .../Cmdlets}/Private/Test-TcpConnection.ps1 | 0 .../Private/Test-TeamViewer32on64.ps1 | 0 .../Public/Add-TeamViewerAssignment.ps1 | 53 +++ .../Public/Add-TeamViewerCustomization.ps1 | 48 +++ .../Public/Add-TeamViewerManagedDevice.ps1 | 0 .../Cmdlets}/Public/Add-TeamViewerManager.ps1 | 0 .../Public/Add-TeamViewerRoleToAccount.ps1 | 64 +++ .../Public/Add-TeamViewerRoleToUserGroup.ps1 | 47 +++ .../Public/Add-TeamViewerSsoExclusion.ps1 | 0 .../Public/Add-TeamViewerUserGroupMember.ps1 | 168 ++++---- .../Cmdlets}/Public/Connect-TeamViewerApi.ps1 | 0 .../Public/Disconnect-TeamViewerApi.ps1 | 0 .../Export-TeamViewerSystemInformation.ps1 | 39 ++ .../Cmdlets}/Public/Get-TeamViewerAccount.ps1 | 0 .../Public/Get-TeamViewerConnectionReport.ps1 | 0 .../Cmdlets}/Public/Get-TeamViewerContact.ps1 | 0 .../Public/Get-TeamViewerCustomModuleId.ps1 | 22 ++ .../Cmdlets}/Public/Get-TeamViewerDevice.ps1 | 0 .../Public/Get-TeamViewerEventLog.ps1 | 0 .../Cmdlets}/Public/Get-TeamViewerGroup.ps1 | 0 .../Cmdlets}/Public/Get-TeamViewerId.ps1 | 0 .../Get-TeamViewerInstallationDirectory.ps1 | 27 ++ .../Public/Get-TeamViewerLogFilePath.ps1 | 38 ++ .../Public/Get-TeamViewerManagedDevice.ps1 | 0 .../Public/Get-TeamViewerManagedGroup.ps1 | 0 .../Public/Get-TeamViewerManagementId.ps1 | 0 .../Cmdlets}/Public/Get-TeamViewerManager.ps1 | 0 .../Cmdlets}/Public/Get-TeamViewerPolicy.ps1 | 0 .../Get-TeamViewerRoleAssignmentToAccount.ps1 | 30 ++ ...et-TeamViewerRoleAssignmentToUserGroup.ps1 | 33 ++ .../Cmdlets}/Public/Get-TeamViewerService.ps1 | 0 .../Public/Get-TeamViewerSsoDomain.ps1 | 0 .../Public/Get-TeamViewerSsoExclusion.ps1 | 0 .../Cmdlets}/Public/Get-TeamViewerUser.ps1 | 0 .../Public/Get-TeamViewerUserGroup.ps1 | 92 ++--- .../Public/Get-TeamViewerUserGroupMember.ps1 | 70 ++-- .../Cmdlets/Public/Get-TeamViewerUserRole.ps1 | 24 ++ .../Cmdlets}/Public/Get-TeamViewerVersion.ps1 | 4 +- .../Invoke-TeamViewerPackageDownload.ps1 | 22 +- .../Cmdlets}/Public/Invoke-TeamViewerPing.ps1 | 0 .../Cmdlets}/Public/New-TeamViewerContact.ps1 | 0 .../Cmdlets}/Public/New-TeamViewerDevice.ps1 | 0 .../Cmdlets}/Public/New-TeamViewerGroup.ps1 | 0 .../Public/New-TeamViewerManagedGroup.ps1 | 0 .../Cmdlets}/Public/New-TeamViewerPolicy.ps1 | 0 .../Cmdlets}/Public/New-TeamViewerUser.ps1 | 0 .../Public/New-TeamViewerUserGroup.ps1 | 62 +-- .../Cmdlets/Public/New-TeamViewerUserRole.ps1 | 47 +++ .../Public/Publish-TeamViewerGroup.ps1 | 0 .../Public/Remove-TeamViewerAssignment.ps1 | 28 ++ .../Public/Remove-TeamViewerContact.ps1 | 0 .../Public/Remove-TeamViewerCustomization.ps1 | 22 ++ .../Public/Remove-TeamViewerDevice.ps1 | 0 .../Public/Remove-TeamViewerGroup.ps1 | 0 .../Public/Remove-TeamViewerManagedDevice.ps1 | 0 ...move-TeamViewerManagedDeviceManagement.ps1 | 0 .../Public/Remove-TeamViewerManagedGroup.ps1 | 0 .../Public/Remove-TeamViewerManager.ps1 | 0 .../Public/Remove-TeamViewerPSProxy.ps1 | 13 + .../Public/Remove-TeamViewerPolicy.ps1 | 0 ...move-TeamViewerPolicyFromManagedDevice.ps1 | 0 .../Remove-TeamViewerRoleFromAccount.ps1 | 63 +++ .../Remove-TeamViewerRoleFromUserGroup.ps1 | 38 ++ .../Public/Remove-TeamViewerSsoExclusion.ps1 | 0 .../Cmdlets}/Public/Remove-TeamViewerUser.ps1 | 0 .../Public/Remove-TeamViewerUserGroup.ps1 | 64 +-- .../Remove-TeamViewerUserGroupMember.ps1 | 190 ++++----- .../Public/Remove-TeamViewerUserRole.ps1 | 31 ++ .../Public/Restart-TeamViewerService.ps1 | 2 +- docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 | 24 ++ .../Cmdlets}/Public/Set-TeamViewerAccount.ps1 | 0 .../Cmdlets}/Public/Set-TeamViewerDevice.ps1 | 0 .../Cmdlets}/Public/Set-TeamViewerGroup.ps1 | 0 .../Public/Set-TeamViewerManagedDevice.ps1 | 0 .../Public/Set-TeamViewerManagedGroup.ps1 | 0 .../Cmdlets}/Public/Set-TeamViewerManager.ps1 | 0 docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 | 21 + .../Cmdlets}/Public/Set-TeamViewerPolicy.ps1 | 0 .../Cmdlets}/Public/Set-TeamViewerUser.ps1 | 0 .../Public/Set-TeamViewerUserGroup.ps1 | 76 ++-- .../Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 54 +++ .../Public/Start-TeamViewerService.ps1 | 0 .../Public/Stop-TeamViewerService.ps1 | 0 .../Public/Test-TeamViewerConnectivity.ps1 | 0 .../Public/Test-TeamViewerInstallation.ps1 | 8 + .../Public/Unpublish-TeamViewerGroup.ps1 | 0 docs/Cmdlets_help/Add-TeamViewerAssignment.md | 98 +++++ .../Add-TeamViewerCustomization.md | 129 ++++++ .../Add-TeamViewerManagedDevice.md | 2 +- .../Add-TeamViewerManager.md | 12 +- .../Add-TeamViewerRoleToAccount.md | 141 +++++++ .../Add-TeamViewerRoleToUserGroup.md | 128 ++++++ .../Add-TeamViewerSsoExclusion.md | 0 .../Add-TeamViewerUserGroupMember.md | 292 +++++++------- .../Connect-TeamViewerApi.md | 2 +- .../Disconnect-TeamViewerApi.md | 2 +- .../Export-TeamViewerSystemInformation.md | 72 ++++ .../Get-TeamViewerAccount.md | 2 +- .../Get-TeamViewerConnectionReport.md | 2 +- .../Get-TeamViewerContact.md | 2 +- .../Get-TeamViewerCustomModuleId.md | 48 +++ .../Get-TeamViewerDevice.md | 2 +- .../Get-TeamViewerEventLog.md | 2 +- .../Get-TeamViewerGroup.md | 2 +- .../Get-TeamViewerId.md | 2 +- .../Get-TeamViewerInstallationDirectory.md | 48 +++ .../Cmdlets_help/Get-TeamViewerLogFilePath.md | 70 ++++ .../Get-TeamViewerManagedDevice.md | 2 +- .../Get-TeamViewerManagedGroup.md | 2 +- .../Get-TeamViewerManagementId.md | 2 +- .../Get-TeamViewerManager.md | 2 +- .../Get-TeamViewerPolicy.md | 2 +- .../Get-TeamViewerRoleAssignmentToAccount.md | 84 ++++ ...Get-TeamViewerRoleAssignmentToUserGroup.md | 84 ++++ .../Get-TeamViewerService.md | 2 +- .../Get-TeamViewerSsoDomain.md | 0 .../Get-TeamViewerSsoExclusion.md | 0 .../Get-TeamViewerUser.md | 4 +- .../Get-TeamViewerUserGroup.md | 186 ++++----- .../Get-TeamViewerUserGroupMember.md | 168 ++++---- docs/Cmdlets_help/Get-TeamViewerUserRole.md | 68 ++++ .../Get-TeamViewerVersion.md | 2 +- .../Invoke-TeamViewerPackageDownload.md | 4 +- .../Invoke-TeamViewerPing.md | 2 +- .../New-TeamViewerContact.md | 2 +- .../New-TeamViewerDevice.md | 2 +- .../New-TeamViewerGroup.md | 2 +- .../New-TeamViewerManagedGroup.md | 2 +- .../New-TeamViewerPolicy.md | 2 +- .../New-TeamViewerUser.md | 2 +- .../New-TeamViewerUserGroup.md | 238 +++++------ docs/Cmdlets_help/New-TeamViewerUserRole.md | 144 +++++++ .../Publish-TeamViewerGroup.md | 2 +- .../Remove-TeamViewerAssignment.md | 48 +++ .../Remove-TeamViewerContact.md | 2 +- .../Remove-TeamViewerCustomization.md | 47 +++ .../Remove-TeamViewerDevice.md | 2 +- .../Remove-TeamViewerGroup.md | 2 +- .../Remove-TeamViewerManagedDevice.md | 2 +- ...emove-TeamViewerManagedDeviceManagement.md | 2 +- .../Remove-TeamViewerManagedGroup.md | 2 +- .../Remove-TeamViewerManager.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerPSProxy.md | 46 +++ .../Remove-TeamViewerPolicy.md | 2 +- ...emove-TeamViewerPolicyFromManagedDevice.md | 0 .../Remove-TeamViewerRoleFromAccount.md | 152 +++++++ .../Remove-TeamViewerRoleFromUserGroup.md | 112 ++++++ .../Remove-TeamViewerSsoExclusion.md | 0 .../Remove-TeamViewerUser.md | 0 .../Remove-TeamViewerUserGroup.md | 248 ++++++------ .../Remove-TeamViewerUserGroupMember.md | 370 +++++++++--------- .../Cmdlets_help/Remove-TeamViewerUserRole.md | 124 ++++++ .../Restart-TeamViewerService.md | 2 +- .../Set-TeamViewerAccount.md | 2 +- .../Set-TeamViewerDevice.md | 2 +- .../Set-TeamViewerGroup.md | 2 +- .../Set-TeamViewerManagedDevice.md | 0 .../Set-TeamViewerManagedGroup.md | 2 +- .../Set-TeamViewerManager.md | 2 +- docs/Cmdlets_help/Set-TeamViewerPSProxy.md | 68 ++++ .../Set-TeamViewerPolicy.md | 2 +- .../Set-TeamViewerUser.md | 2 +- .../Set-TeamViewerUserGroup.md | 270 ++++++------- docs/Cmdlets_help/Set-TeamViewerUserRole.md | 130 ++++++ .../Start-TeamViewerService.md | 2 +- .../Stop-TeamViewerService.md | 2 +- .../Test-TeamViewerConnectivity.md | 2 +- .../Test-TeamViewerInstallation.md | 2 +- .../Unpublish-TeamViewerGroup.md | 2 +- {TeamViewerPS => docs}/TeamViewerPS.Types.ps1 | 0 .../TeamViewerPS.format.ps1xml | 0 {TeamViewerPS => docs}/TeamViewerPS.psd1 | 2 +- {TeamViewerPS => docs}/TeamViewerPS.psm1 | 4 +- docs/about_TeamViewerPS.md | 120 +++--- 326 files changed, 5903 insertions(+), 1717 deletions(-) rename .spelling => .vscode/.spelling (100%) rename Build/{New-TeamViewerPSPackage.ps1 => New-Package.ps1} (64%) rename LICENSE => LICENSE.md (100%) create mode 100644 Linters/PSScriptAnalyzer.psd1 delete mode 100644 PSScriptAnalyzerSettings.psd1 delete mode 100644 TeamViewerPS/Private/Get-TeamViewerApiUri.ps1 delete mode 100644 TeamViewerPS/Public/Test-TeamViewerInstallation.ps1 create mode 100644 Tests/Public/Add-TeamViewerAssignment.Tests.ps1 create mode 100644 Tests/Public/Add-TeamViewerCustomization.Tests.ps1 create mode 100644 Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 create mode 100644 Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 create mode 100644 Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 create mode 100644 Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 create mode 100644 Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 create mode 100644 Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 create mode 100644 Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 create mode 100644 Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 create mode 100644 Tests/Public/Get-TeamViewerUserRole.Tests.ps1 create mode 100644 Tests/Public/New-TeamViewerUserRole.tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 create mode 100644 Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 create mode 100644 Tests/Public/Set-TeamViewerUserRole.Tests.ps1 create mode 100644 docs/Cmdlets/Private/Add-Registry.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-DateTime.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-ErrorRecord.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerAccount.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerAuditEvent.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerConnectionReport.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerContact.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerGroupShare.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerManagedDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerManagedGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerManager.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerPolicy.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerRestError.ps1 (100%) create mode 100644 docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 create mode 100644 docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerSsoDomain.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerUser.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerUserGroup.ps1 (96%) rename {TeamViewerPS => docs/Cmdlets}/Private/ConvertTo-TeamViewerUserGroupMember.ps1 (96%) create mode 100644 docs/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 create mode 100644 docs/Cmdlets/Private/Get-ClientId.ps1 create mode 100644 docs/Cmdlets/Private/Get-HostFile.ps1 create mode 100644 docs/Cmdlets/Private/Get-InstalledSoftware.ps1 create mode 100644 docs/Cmdlets/Private/Get-IpConfig.ps1 create mode 100644 docs/Cmdlets/Private/Get-MSInfo32.ps1 create mode 100644 docs/Cmdlets/Private/Get-NSLookUpData.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/Get-OperatingSystem.ps1 (100%) create mode 100644 docs/Cmdlets/Private/Get-RegistryPath.ps1 create mode 100644 docs/Cmdlets/Private/Get-RouteTable.ps1 create mode 100644 docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 create mode 100644 docs/Cmdlets/Private/Get-TSCSearchDirectory.ps1 create mode 100644 docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/Get-TeamViewerLinuxGlobalConfig.ps1 (74%) rename {TeamViewerPS => docs/Cmdlets}/Private/Get-TeamViewerRegKeyPath.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Get-TeamViewerServiceName.ps1 (100%) create mode 100644 docs/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/Invoke-ExternalCommand.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Invoke-TeamViewerRestMethod.ps1 (75%) create mode 100644 docs/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 create mode 100644 docs/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerContactId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerDeviceId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerGroupId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerLanguage.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerManagedDeviceId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerManagedGroupId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerManagerId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerPolicyId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerSsoDomainId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerUserEmail.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerUserGroupId.ps1 (97%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerUserGroupMemberId.ps1 (97%) rename {TeamViewerPS => docs/Cmdlets}/Private/Resolve-TeamViewerUserId.ps1 (100%) create mode 100644 docs/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 rename {TeamViewerPS => docs/Cmdlets}/Private/Test-TcpConnection.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Private/Test-TeamViewer32on64.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1 create mode 100644 docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Add-TeamViewerManagedDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Add-TeamViewerManager.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 create mode 100644 docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Add-TeamViewerSsoExclusion.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Add-TeamViewerUserGroupMember.ps1 (97%) rename {TeamViewerPS => docs/Cmdlets}/Public/Connect-TeamViewerApi.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Disconnect-TeamViewerApi.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerAccount.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerConnectionReport.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerContact.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerEventLog.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerId.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 create mode 100644 docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerManagedDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerManagedGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerManagementId.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerManager.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerPolicy.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 create mode 100644 docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerService.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerSsoDomain.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerSsoExclusion.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerUser.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerUserGroup.ps1 (96%) rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerUserGroupMember.ps1 (96%) create mode 100644 docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Get-TeamViewerVersion.ps1 (52%) rename {TeamViewerPS => docs/Cmdlets}/Public/Invoke-TeamViewerPackageDownload.ps1 (73%) rename {TeamViewerPS => docs/Cmdlets}/Public/Invoke-TeamViewerPing.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerContact.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerManagedGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerPolicy.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerUser.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/New-TeamViewerUserGroup.ps1 (96%) create mode 100644 docs/Cmdlets/Public/New-TeamViewerUserRole.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Publish-TeamViewerGroup.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerContact.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerManagedDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerManagedDeviceManagement.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerManagedGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerManager.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerPolicy.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 create mode 100644 docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerSsoExclusion.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerUser.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerUserGroup.ps1 (96%) rename {TeamViewerPS => docs/Cmdlets}/Public/Remove-TeamViewerUserGroupMember.ps1 (97%) create mode 100644 docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Restart-TeamViewerService.ps1 (87%) create mode 100644 docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerAccount.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerManagedDevice.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerManagedGroup.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerManager.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerPolicy.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerUser.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Set-TeamViewerUserGroup.ps1 (97%) create mode 100644 docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Start-TeamViewerService.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Stop-TeamViewerService.ps1 (100%) rename {TeamViewerPS => docs/Cmdlets}/Public/Test-TeamViewerConnectivity.ps1 (100%) create mode 100644 docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1 rename {TeamViewerPS => docs/Cmdlets}/Public/Unpublish-TeamViewerGroup.ps1 (100%) create mode 100644 docs/Cmdlets_help/Add-TeamViewerAssignment.md create mode 100644 docs/Cmdlets_help/Add-TeamViewerCustomization.md rename docs/{commands => Cmdlets_help}/Add-TeamViewerManagedDevice.md (98%) rename docs/{commands => Cmdlets_help}/Add-TeamViewerManager.md (99%) create mode 100644 docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md create mode 100644 docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md rename docs/{commands => Cmdlets_help}/Add-TeamViewerSsoExclusion.md (100%) rename docs/{commands => Cmdlets_help}/Add-TeamViewerUserGroupMember.md (93%) rename docs/{commands => Cmdlets_help}/Connect-TeamViewerApi.md (96%) rename docs/{commands => Cmdlets_help}/Disconnect-TeamViewerApi.md (95%) create mode 100644 docs/Cmdlets_help/Export-TeamViewerSystemInformation.md rename docs/{commands => Cmdlets_help}/Get-TeamViewerAccount.md (96%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerConnectionReport.md (99%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerContact.md (98%) create mode 100644 docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md rename docs/{commands => Cmdlets_help}/Get-TeamViewerDevice.md (98%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerEventLog.md (99%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerGroup.md (98%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerId.md (95%) create mode 100644 docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md create mode 100644 docs/Cmdlets_help/Get-TeamViewerLogFilePath.md rename docs/{commands => Cmdlets_help}/Get-TeamViewerManagedDevice.md (98%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerManagedGroup.md (97%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerManagementId.md (94%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerManager.md (97%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerPolicy.md (97%) create mode 100644 docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md create mode 100644 docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md rename docs/{commands => Cmdlets_help}/Get-TeamViewerService.md (95%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerSsoDomain.md (100%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerSsoExclusion.md (100%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerUser.md (97%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerUserGroup.md (92%) rename docs/{commands => Cmdlets_help}/Get-TeamViewerUserGroupMember.md (92%) create mode 100644 docs/Cmdlets_help/Get-TeamViewerUserRole.md rename docs/{commands => Cmdlets_help}/Get-TeamViewerVersion.md (95%) rename docs/{commands => Cmdlets_help}/Invoke-TeamViewerPackageDownload.md (93%) rename docs/{commands => Cmdlets_help}/Invoke-TeamViewerPing.md (96%) rename docs/{commands => Cmdlets_help}/New-TeamViewerContact.md (98%) rename docs/{commands => Cmdlets_help}/New-TeamViewerDevice.md (98%) rename docs/{commands => Cmdlets_help}/New-TeamViewerGroup.md (98%) rename docs/{commands => Cmdlets_help}/New-TeamViewerManagedGroup.md (97%) rename docs/{commands => Cmdlets_help}/New-TeamViewerPolicy.md (98%) rename docs/{commands => Cmdlets_help}/New-TeamViewerUser.md (99%) rename docs/{commands => Cmdlets_help}/New-TeamViewerUserGroup.md (93%) create mode 100644 docs/Cmdlets_help/New-TeamViewerUserRole.md rename docs/{commands => Cmdlets_help}/Publish-TeamViewerGroup.md (98%) create mode 100644 docs/Cmdlets_help/Remove-TeamViewerAssignment.md rename docs/{commands => Cmdlets_help}/Remove-TeamViewerContact.md (97%) create mode 100644 docs/Cmdlets_help/Remove-TeamViewerCustomization.md rename docs/{commands => Cmdlets_help}/Remove-TeamViewerDevice.md (97%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerGroup.md (97%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerManagedDevice.md (98%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerManagedDeviceManagement.md (97%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerManagedGroup.md (97%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerManager.md (98%) create mode 100644 docs/Cmdlets_help/Remove-TeamViewerPSProxy.md rename docs/{commands => Cmdlets_help}/Remove-TeamViewerPolicy.md (97%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerPolicyFromManagedDevice.md (100%) create mode 100644 docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md create mode 100644 docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md rename docs/{commands => Cmdlets_help}/Remove-TeamViewerSsoExclusion.md (100%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerUser.md (100%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerUserGroup.md (93%) rename docs/{commands => Cmdlets_help}/Remove-TeamViewerUserGroupMember.md (93%) create mode 100644 docs/Cmdlets_help/Remove-TeamViewerUserRole.md rename docs/{commands => Cmdlets_help}/Restart-TeamViewerService.md (96%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerAccount.md (98%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerDevice.md (99%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerGroup.md (98%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerManagedDevice.md (100%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerManagedGroup.md (98%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerManager.md (99%) create mode 100644 docs/Cmdlets_help/Set-TeamViewerPSProxy.md rename docs/{commands => Cmdlets_help}/Set-TeamViewerPolicy.md (98%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerUser.md (99%) rename docs/{commands => Cmdlets_help}/Set-TeamViewerUserGroup.md (93%) create mode 100644 docs/Cmdlets_help/Set-TeamViewerUserRole.md rename docs/{commands => Cmdlets_help}/Start-TeamViewerService.md (96%) rename docs/{commands => Cmdlets_help}/Stop-TeamViewerService.md (96%) rename docs/{commands => Cmdlets_help}/Test-TeamViewerConnectivity.md (96%) rename docs/{commands => Cmdlets_help}/Test-TeamViewerInstallation.md (94%) rename docs/{commands => Cmdlets_help}/Unpublish-TeamViewerGroup.md (97%) rename {TeamViewerPS => docs}/TeamViewerPS.Types.ps1 (100%) rename {TeamViewerPS => docs}/TeamViewerPS.format.ps1xml (100%) rename {TeamViewerPS => docs}/TeamViewerPS.psd1 (99%) rename {TeamViewerPS => docs}/TeamViewerPS.psm1 (54%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index deeba7d..1dbd115 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,48 +2,48 @@ name: CI # Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ main ] - pull_request: - branches: [ main ] + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [main] + pull_request: + branches: [main] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: jobs: - verify: - runs-on: ubuntu-latest + verify: + runs-on: windows-latest - steps: - # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it - - uses: actions/checkout@v3 + steps: + # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it + - uses: actions/checkout@v3 - # Print Powershell version - - name: Powershell Environment - shell: pwsh - run: | - $PSVersionTable - # Run linter - - name: Run linter (via PSScriptAnalyzer) - shell: pwsh - run: | - $ProgressPreference = 'SilentlyContinue' - $ErrorActionPreference = 'Stop' - Install-Module -Name PSScriptAnalyzer -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 1.19.1 -Force -Verbose - Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -Settings (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'PSScriptAnalyzerSettings.psd1') -ReportSummary -EnableExit - # Run tests - - name: Run tests (via Pester) - shell: pwsh - run: | - $ProgressPreference = 'SilentlyContinue' - Install-Module -Name Pester -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 5.1.1 -Force -Verbose - Invoke-Pester -Path $env:GITHUB_WORKSPACE -Output Detailed -CI - # Build package - - name: Package Build - shell: pwsh - run: | - $ProgressPreference = 'SilentlyContinue' - $ErrorActionPreference = 'Stop' - Install-Module -Name platyPS, BuildHelpers -SkipPublisherCheck -Scope CurrentUser -Force - & $env:GITHUB_WORKSPACE/Build/New-TeamViewerPSPackage.ps1 -Verbose + # Print Powershell version + - name: Powershell Environment + shell: pwsh + run: | + $PSVersionTable + # Run linter + - name: Run linter (via PSScriptAnalyzer) + shell: pwsh + run: | + $ProgressPreference = 'SilentlyContinue' + $ErrorActionPreference = 'Stop' + Install-Module -Name PSScriptAnalyzer -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 1.19.1 -Force -Verbose + Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -Settings (Join-Path -Path $env:GITHUB_WORKSPACE/Linters -ChildPath 'PSScriptAnalyzer.psd1') -ReportSummary -EnableExit + # Run tests + - name: Run tests (via Pester) + shell: pwsh + run: | + $ProgressPreference = 'SilentlyContinue' + Install-Module -Name Pester -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 5.1.1 -Force -Verbose + Invoke-Pester -Path $env:GITHUB_WORKSPACE -Output Detailed -CI + # Build package + - name: Package Build + shell: pwsh + run: | + $ProgressPreference = 'SilentlyContinue' + $ErrorActionPreference = 'Stop' + Install-Module -Name platyPS, BuildHelpers -SkipPublisherCheck -Scope CurrentUser -Force + & $env:GITHUB_WORKSPACE/Build/New-Package.ps1 -Verbose diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index a8dc0aa..27cb284 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -20,7 +20,7 @@ on: jobs: build: name: PSScriptAnalyzer - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 4ba1430..ff69da6 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -7,7 +7,7 @@ on: jobs: publish: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v2 @@ -17,7 +17,7 @@ jobs: run: | $ProgressPreference='SilentlyContinue' Install-Module platyPS,BuildHelpers -Force -SkipPublisherCheck -Scope CurrentUser - & $env:GITHUB_WORKSPACE/Build/New-TeamViewerPSPackage.ps1 -Verbose + & $env:GITHUB_WORKSPACE/Build/New-Package.ps1 -Verbose - name: Publish to powershellgallery.com env: @@ -26,5 +26,5 @@ jobs: run: | $ProgressPreference='SilentlyContinue' Publish-Module ` - -Path $env:GITHUB_WORKSPACE/BuildOutput/TeamViewerPS/ ` + -Path $env:GITHUB_WORKSPACE/Build/Output/ ` -NuGetApiKey $env:NUGET_APIKEY_PRODUCTION diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index bcb105e..11b03b6 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -5,7 +5,7 @@ on: jobs: publish: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v2 @@ -15,7 +15,7 @@ jobs: run: | $ProgressPreference='SilentlyContinue' Install-Module platyPS,BuildHelpers -Force -SkipPublisherCheck -Scope CurrentUser - & $env:GITHUB_WORKSPACE/Build/New-TeamViewerPSPackage.ps1 -Verbose + & $env:GITHUB_WORKSPACE/Build/New-Package.ps1 -Verbose - name: Publish to poshtestgallery.com env: @@ -27,7 +27,7 @@ jobs: -Name PSTestGallery ` -SourceLocation https://www.poshtestgallery.com/api/v2 Publish-Module ` - -Path $env:GITHUB_WORKSPACE/BuildOutput/TeamViewerPS/ ` + -Path $env:GITHUB_WORKSPACE/Build/Output/ ` -NuGetApiKey $env:NUGET_APIKEY_TESTING ` -Repository PSTestGallery ` -Force diff --git a/.gitignore b/.gitignore index 17506b0..9585e52 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/BuildOutput +/Build/Output diff --git a/.spelling b/.vscode/.spelling similarity index 100% rename from .spelling rename to .vscode/.spelling diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a68e5ee..9274ea4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,7 +5,7 @@ { "label": "Lint (via PSScriptAnalyzer)", "type": "shell", - "command": "Invoke-ScriptAnalyzer -Path '${workspaceFolder}' -Severity Information, Warning, Error -Recurse", + "command": "Invoke-ScriptAnalyzer -Path '${workspaceFolder}/Linters' -Severity Information, Warning, Error -Recurse", "group": { "kind": "build", "isDefault": true diff --git a/Build/New-TeamViewerPSPackage.ps1 b/Build/New-Package.ps1 similarity index 64% rename from Build/New-TeamViewerPSPackage.ps1 rename to Build/New-Package.ps1 index c608dfe..da19d4f 100644 --- a/Build/New-TeamViewerPSPackage.ps1 +++ b/Build/New-Package.ps1 @@ -3,7 +3,7 @@ param( [Parameter()] [string] - $BuildOutputPath = "$(Resolve-Path "$PSScriptRoot/..")/BuildOutput" + $BuildOutputPath = "$(Resolve-Path "$PSScriptRoot/..")/Build/Output" ) $repoPath = Resolve-Path "$PSScriptRoot/.." @@ -14,18 +14,18 @@ if (Test-Path $BuildOutputPath) { } Write-Verbose 'Creating build output directories.' New-Item -Type Directory $BuildOutputPath | Out-Null -New-Item -Type Directory "$BuildOutputPath/TeamViewerPS" | Out-Null + # Compile all functions into a single psm file -$targetFile = "$BuildOutputPath/TeamViewerPS/TeamViewerPS.psm1" +$targetFile = "$BuildOutputPath/TeamViewerPS.psm1" Write-Verbose 'Compiling single-file TeamViewer module.' -$ModuleTypes = @(Get-ChildItem -Path "$repoPath/TeamViewerPS/TeamViewerPS.Types.ps1") +$ModuleTypes = @(Get-ChildItem -Path "$repoPath/Docs/TeamViewerPS.Types.ps1") $PrivateFunctions = @(Get-ChildItem ` - -Path "$repoPath/TeamViewerPS/Private/*.ps1" ` + -Path "$repoPath/Docs/Cmdlets/Private/*.ps1" ` -ErrorAction SilentlyContinue) Write-Verbose "Found $($PrivateFunctions.Count) private function files." $PublicFunctions = @(Get-ChildItem ` - -Path "$repoPath/TeamViewerPS/Public/*.ps1" ` + -Path "$repoPath/Docs/Cmdlets/Public/*.ps1" ` -ErrorAction SilentlyContinue) Write-Verbose "Found $($PublicFunctions.Count) public function files." @($ModuleTypes + $PrivateFunctions + $PublicFunctions) | ` @@ -36,24 +36,24 @@ Write-Verbose "Found $($PublicFunctions.Count) public function files." # Create help from markdown Write-Verbose 'Building help from Markdown' New-ExternalHelp ` - -Path "$repoPath/docs" ` - -OutputPath "$BuildOutputPath/TeamViewerPS/en-US" | ` + -Path "$repoPath/Docs" ` + -OutputPath "$BuildOutputPath/en-US" | ` Out-Null New-ExternalHelp ` - -Path "$repoPath/docs/commands" ` - -OutputPath "$BuildOutputPath/TeamViewerPS/en-US" | ` + -Path "$repoPath/Docs/Cmdlets_help" ` + -OutputPath "$BuildOutputPath/en-US" | ` Out-Null # Create module manifest Write-Verbose 'Creating module manifest' Copy-Item ` - -Path "$repoPath/TeamViewerPS/TeamViewerPS.psd1" ` - -Destination "$BuildOutputPath/TeamViewerPS/" + -Path "$repoPath/Docs/TeamViewerPS.psd1" ` + -Destination "$BuildOutputPath/" Copy-Item ` - -Path "$repoPath/TeamViewerPS/*.format.ps1xml" ` - -Destination "$BuildOutputPath/TeamViewerPS/" + -Path "$repoPath/Docs/*.format.ps1xml" ` + -Destination "$BuildOutputPath/" Update-Metadata ` - -Path "$BuildOutputPath/TeamViewerPS/TeamViewerPS.psd1" ` + -Path "$BuildOutputPath/TeamViewerPS.psd1" ` -PropertyName 'FunctionsToExport' ` -Value $PublicFunctions.BaseName @@ -61,14 +61,14 @@ Update-Metadata ` Write-Verbose 'Copying additional files into the package' Copy-Item ` -Path ` - "$repoPath/LICENSE", ` + "$repoPath/LICENSE.md", ` "$repoPath/CHANGELOG.md", ` "$repoPath/README.md"` - -Destination "$BuildOutputPath/TeamViewerPS/" + -Destination "$BuildOutputPath/" Write-Verbose 'Listing package files:' Push-Location $BuildOutputPath -Get-ChildItem -Recurse "$BuildOutputPath/TeamViewerPS" | ` +Get-ChildItem -Recurse "$BuildOutputPath/" | ` Sort-Object -Property FullName | ` Resolve-Path -Relative Pop-Location diff --git a/CHANGELOG.md b/CHANGELOG.md index f53495d..6489fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Change Log +## 2.0.0 (2023-09-13) + +### Added + + -Added 'Set-TeamViewerApiURi' to use TeamViewer test API. + -Added user role commands to remotely manage user roles of a TeamViewer company. + -Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. + -Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. + -Added `Export-TeamViewerSystemInformation` to create zip file for support. + -Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. + -Added `Get-TeamViewerInstallationDirectory` to return installation directory. + +### Changed + + -Extended `Invoke-TeamViewerPackageDownload` with MSI package type. + -Folder structure modified. + +### Fixed + + -Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. + ## 1.5.1 (2023-07-18) - Improved `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md diff --git a/Linters/PSScriptAnalyzer.psd1 b/Linters/PSScriptAnalyzer.psd1 new file mode 100644 index 0000000..a327eb8 --- /dev/null +++ b/Linters/PSScriptAnalyzer.psd1 @@ -0,0 +1,4 @@ +@{ + Severity = @('Error', 'Warning') + ExcludeRules = @('PSUseToExportFieldsInManifest','PSAvoidGlobalVars') +} diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 deleted file mode 100644 index 8d6610f..0000000 --- a/PSScriptAnalyzerSettings.psd1 +++ /dev/null @@ -1,4 +0,0 @@ -@{ - Severity = @('Error', 'Warning', 'Information') - ExcludeRules = @('PSUseToExportFieldsInManifest') -} diff --git a/TeamViewerPS/Private/Get-TeamViewerApiUri.ps1 b/TeamViewerPS/Private/Get-TeamViewerApiUri.ps1 deleted file mode 100644 index 404d1ed..0000000 --- a/TeamViewerPS/Private/Get-TeamViewerApiUri.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -function Get-TeamViewerApiUri { - Write-Output 'https://webapi.teamviewer.com/api/v1' -} diff --git a/TeamViewerPS/Public/Test-TeamViewerInstallation.ps1 b/TeamViewerPS/Public/Test-TeamViewerInstallation.ps1 deleted file mode 100644 index 70e2fd1..0000000 --- a/TeamViewerPS/Public/Test-TeamViewerInstallation.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -function Test-TeamViewerInstallation { - switch (Get-OperatingSystem) { - 'Windows' { - $regKey = Get-TeamViewerRegKeyPath - $installationDirectory = if (Test-Path $regKey) { (Get-Item $regKey).GetValue('InstallationDirectory') } - Write-Output ( - $installationDirectory -And ` - (Test-Path "$installationDirectory/TeamViewer.exe") - ) - } - 'Linux' { - Write-Output ( - (Test-Path '/opt/teamviewer/tv_bin/TeamViewer') - ) - } - default { $false } - } -} diff --git a/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 b/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 new file mode 100644 index 0000000..83c150b --- /dev/null +++ b/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 @@ -0,0 +1,68 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerVersion.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } +} +Describe 'Add-TeamViewerAssignment' { + Context 'Windows' { + BeforeAll { + # Testing independent behavior using mocked dependencies + Mock Get-TeamViewerInstallationDirectory { 'testPath' } + Mock Get-TeamViewerVersion { '15.50' } + Mock Test-TeamViewerInstallation { $true } + Mock Set-Location {} + Mock Start-Process {} + Mock Resolve-AssignmentErrorCode {} + Mock Start-Process { + $process = New-Object PSObject -Property @{ + ExitCode = 0 + } + $process + } + } + + It 'Should set the location to the installation directory' { + Add-TeamViewerAssignment -AssignmentId '123' -DeviceAlias 'TestAlias' -Retries 3 + Assert-MockCalled Set-Location -Scope It -Times 1 -ParameterFilter { + $Path -eq 'testPath' + } + } + + It 'Should call TeamViewer.exe assignment with device alias and retries' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'assignment --id 123 --device-alias=TestAlias --retries=3' } + Add-TeamViewerAssignment -AssignmentId '123' -DeviceAlias 'TestAlias' -Retries 3 + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should call TeamViewer.exe assignment with device alias' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'assignment --id 123 --device-alias=TestAlias' } + Add-TeamViewerAssignment -AssignmentId '123' -DeviceAlias 'TestAlias' + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should call TeamViewer.exe assignment with retries' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'assignment --id 123 --retries=3' } + Add-TeamViewerAssignment -AssignmentId '123' -Retries 3 + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should call TeamViewer.exe assignment without device alias or retries' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'assignment --id 123' } + Add-TeamViewerAssignment -AssignmentId '123' + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should restore the current directory after calling cmd.exe' { + $currentDirectory = Get-Location + Add-TeamViewerAssignment -AssignmentId '123' -DeviceAlias 'TestAlias' + Assert-MockCalled Set-Location -Scope It -Times 1 -ParameterFilter { + $Path -eq $currentDirectory + } + } + } +} + + diff --git a/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 b/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 new file mode 100644 index 0000000..ce9e1e5 --- /dev/null +++ b/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 @@ -0,0 +1,79 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } +} + +Describe 'Add-TeamViewerCustomization' { + Context 'When only Id is provided' { + BeforeAll { + Mock Test-TeamViewerInstallation { $true } + Mock Get-TeamViewerInstallationDirectory { 'testpath' } + Mock Set-Location + Mock Start-Process { + $process = New-Object PSObject -Property @{ + ExitCode = 0 + } + $process + } + Mock Resolve-CustomizationErrorCode {} + } + + It 'Should call TeamViewer.exe customize with the provided Id' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'customize --id 123"' } + Add-TeamViewerCustomization -Id '123' + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should resolve the customization error code' { + Mock Resolve-CustomizationErrorCode {} + Add-TeamViewerCustomization -Id '123' + Assert-MockCalled Resolve-CustomizationErrorCode -Scope It -Times 1 + } + } + + Context 'When only Path is provided' { + BeforeAll { + Mock Test-TeamViewerInstallation { $true } + Mock Get-TeamViewerInstallationDirectory { 'testpath' } + Mock Set-Location + Mock Start-Process { + $process = New-Object PSObject -Property @{ + ExitCode = 0 + } + $process + } + Mock Resolve-CustomizationErrorCode {} + } + + It 'Should call TeamViewer.exe customize with the provided Path' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'customize --path C:\TeamViewer.zip"' } + Add-TeamViewerCustomization -Path 'C:\TeamViewer.zip' + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should resolve the customization error code' { + Mock Resolve-CustomizationErrorCode {} + Add-TeamViewerCustomization -Path 'C:\TeamViewer.zip' + Assert-MockCalled Resolve-CustomizationErrorCode -Scope It -Times 1 + } + } + + + Context 'When TeamViewer is not installed' { + BeforeAll { + Mock Test-TeamViewerInstallation { $false } + Mock Write-Error {} + Mock Start-Process {} + } + + It 'Should write an error message' { + Mock Write-Error -ParameterFilter { $_ -eq 'TeamViewer is not installed' } + Add-TeamViewerCustomization -Id '123' + Assert-MockCalled Start-Process -Scope It -Times 0 + Assert-MockCalled Write-Error -Scope It -Times 1 + } + } +} diff --git a/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 index 3b75729..e4997a2 100644 --- a/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Add-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerManager.Tests.ps1 b/Tests/Public/Add-TeamViewerManager.Tests.ps1 index cbc2b95..dd605dc 100644 --- a/Tests/Public/Add-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Add-TeamViewerManager.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 new file mode 100644 index 0000000..ab247ef --- /dev/null +++ b/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 @@ -0,0 +1,61 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testAccount = @('u123', 'u124') + $null = $testAccount + $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testUserRoleId + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body + @{ + UserIds = @($testAccount) + UserRoleId = $testUserRoleId + } + } +} +Describe 'Add-TeamViewerRoleToAccount' { + + It 'Should call the correct API endpoint' { + Add-TeamViewerRoleToAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles/assign/account' -And ` + $Method -eq 'Post' + } + } + + + It 'Should assign the given account to the user role' { + Add-TeamViewerRoleToAccount ` + -ApiToken $testApiToken ` + -UserRoleId $testUserRoleId ` + -Accounts $testAccount + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.UserIds | Should -HaveCount 2 + foreach ($id in $testAccount) { + $body.UserIds | Should -Contain $id + } + $body.UserRoleId | Should -Be $testUserRoleId + } + + It 'Should accept pipeline input' { + $testAccount | Add-TeamViewerRoleToAccount ` + -ApiToken $testApiToken ` + -UserRoleId $testUserRoleId + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.UserIds | Should -HaveCount 2 + foreach ($id in $testAccount) { + $body.UserIds | Should -Contain $id + } + $body.UserRoleId | Should -Be $testUserRoleId + } +} diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 new file mode 100644 index 0000000..0d6dec6 --- /dev/null +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testUserGroup = 1234 + $null = $testUserGroup + $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testUserRoleId + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body + @{ + UserRoleId = $testUserRoleId + UserGroupId = $testUserGroup + } + } +} +Describe 'Add-TeamViewerRoleToUserGroup' { + + It 'Should call the correct API endpoint' { + Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` + $Method -eq 'Post' + } + } + + # It 'Should return a UserRole/UserGroup object' { + #Request doesn't return a response body + # } + + +} diff --git a/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 b/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 index 77ca1aa..2c4842f 100644 --- a/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Add-TeamViewerSsoExclusion.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 index 9b6e02f..571fb6e 100644 --- a/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Connect-TeamViewerApi.Tests.ps1 b/Tests/Public/Connect-TeamViewerApi.Tests.ps1 index 284312e..3d42fb5 100644 --- a/Tests/Public/Connect-TeamViewerApi.Tests.ps1 +++ b/Tests/Public/Connect-TeamViewerApi.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Invoke-TeamViewerPing.ps1" - . "$PSScriptRoot/../../TeamViewerPS/Public/Connect-TeamViewerApi.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Connect-TeamViewerApi.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 b/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 index dff83ae..494b067 100644 --- a/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 +++ b/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Disconnect-TeamViewerApi.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Disconnect-TeamViewerApi.ps1" } Describe 'Disconnect-TeamViewerApi' { diff --git a/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 b/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 new file mode 100644 index 0000000..58610ba --- /dev/null +++ b/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 @@ -0,0 +1,55 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + Mock -CommandName Test-TeamViewerInstallation { return $true } + Mock -CommandName Get-OperatingSystem { return 'Windows' } + Mock -CommandName Get-Location { return 'C:\Temp' } + Mock -CommandName Get-TSCDirectoryFile { return } + Mock -CommandName Get-InstalledSoftware { return } + Mock -CommandName Get-IpConfig { return } + Mock -CommandName Get-MSInfo32 { return } + Mock -CommandName Get-HostFile { return } + Mock -CommandName Get-NSLookUpData { return } + Mock -CommandName Get-RouteTable { return } + Mock -CommandName Get-RegistryPath { return } + Mock -CommandName Get-ClientId { return '12345' } + Mock -CommandName Compress-Archive { return } + Mock -CommandName Test-Path { return $true } + Mock -CommandName Copy-Item {return} +} + +Describe "Export-TeamViewerSystemInformation" { + Context "When TeamViewer is installed on Windows" { + It "Should create a zip file with the correct name" { + $TargetDirectory = 'C:\' + $TempPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.Guid]::NewGuid().ToString()) + $ZipFileName = 'TV_SC_12345_WINPS.zip' + $ZipPath = Join-Path -Path "$TempPath\Data" -ChildPath $ZipFileName + $CompressPath = Compress-Archive -Path $Temp\* -DestinationPath $ZipPath -Force + Mock -CommandName "Join-Path" -MockWith { $ZipPath } + Mock -CommandName "Copy-Item" -MockWith {$null} + Mock -CommandName "Compress-Archive" -MockWith { $CompressPath } + Export-TeamViewerSystemInformation -TargetDirectory $TargetDirectory + Assert-MockCalled -CommandName "Join-Path" -Exactly -Times 1 + Assert-MockCalled -CommandName "Compress-Archive" -Times 1 + } + } + + Context "When TeamViewer is not installed" { + BeforeAll { + Mock -CommandName Test-TeamViewerInstallation -MockWith { return $false } + Mock -CommandName Write-Error -MockWith { return } + } + + It "Should write an error message" { + Mock -CommandName "Write-Error" -MockWith { $null } + Export-TeamViewerSystemInformation + Assert-MockCalled -CommandName "Write-Error" -Exactly -Times 1 + } + } +} + + diff --git a/Tests/Public/Get-TeamViewerAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerAccount.Tests.ps1 index 0076f9a..395b6ce 100644 --- a/Tests/Public/Get-TeamViewerAccount.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerAccount.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerAccount.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 b/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 index fa5847f..62aad8b 100644 --- a/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/TeamViewerPS.Types.ps1" - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1" + . "$PSScriptRoot/../../Docs/TeamViewerPS.Types.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} @@ -52,7 +52,7 @@ Describe 'Get-TeamViewerConnectionReport' { It 'Should fetch consecutive pages' { Mock Invoke-TeamViewerRestMethod { @{ - records = @( + records = @( @{ id = '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' userid = 'u1234' @@ -67,7 +67,7 @@ Describe 'Get-TeamViewerConnectionReport' { next_offset = '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' } } Mock Invoke-TeamViewerRestMethod { @{ - records = @( + records = @( @{ id = '5ae6d2a9-57e9-4c62-b236-280390954b6f' userid = 'u5678' @@ -81,7 +81,7 @@ Describe 'Get-TeamViewerConnectionReport' { ) next_offset = '5ae6d2a9-57e9-4c62-b236-280390954b6f' } } -ParameterFilter { $Body.offset_id -eq '0755a8dd-df19-4ea7-af47-cabb6b2a97e4' } - Mock Invoke-TeamViewerRestMethod { @{ + Mock Invoke-TeamViewerRestMethod { @{ records = @( @{ id = '018d007c-9faf-474a-b39a-4021251860e7' @@ -96,6 +96,7 @@ Describe 'Get-TeamViewerConnectionReport' { ) } } -ParameterFilter { $Body.offset_id -eq '5ae6d2a9-57e9-4c62-b236-280390954b6f' } + $result = Get-TeamViewerConnectionReport -ApiToken $testApiToken $result | Should -HaveCount 3 Assert-MockCalled Invoke-TeamViewerRestMethod -Times 3 -Scope It diff --git a/Tests/Public/Get-TeamViewerContact.Tests.ps1 b/Tests/Public/Get-TeamViewerContact.Tests.ps1 index f2cef41..e65a62c 100644 --- a/Tests/Public/Get-TeamViewerContact.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerContact.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerContact.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerContact.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 b/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 new file mode 100644 index 0000000..2ebd483 --- /dev/null +++ b/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 @@ -0,0 +1,45 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } +} + +Describe 'Get-TeamViewerCustomModuleId' { + Context 'When TeamViewer is installed and customization is applied' { + BeforeAll { + Mock Test-TeamViewerInstallation { $true } + Mock Test-Path { $true } + Mock Get-Content { '{"id": "customModuleId"}' } + Mock Get-TeamViewerInstallationDirectory {return 'C:\'} + $installationDirectory = Get-TeamViewerInstallationDirectory + $fileName ='TeamViewer.Json' + $filePath = Join-Path -Path $installationDirectory -ChildPath $fileName + Mock -CommandName Join-Path -MockWith {$filePath} + } + + It 'Should return the custom module ID' { + $expectedId = 'customModuleId' + $result = Get-TeamViewerCustomModuleId + $result | Should -Be $expectedId + } + } + + + Context 'When TeamViewer is not installed' { + BeforeAll { + Mock Test-TeamViewerInstallation { $false } + Mock Write-Error {} + } + + It 'Should write an error message' { + Mock Write-Error -ParameterFilter { $_ -eq 'TeamViewer is not installed' } + Get-TeamViewerCustomModuleId + Assert-MockCalled Write-Error -Scope It -Times 1 + } + } + +} + + diff --git a/Tests/Public/Get-TeamViewerDevice.Tests.ps1 b/Tests/Public/Get-TeamViewerDevice.Tests.ps1 index 7e47d82..eea87a7 100644 --- a/Tests/Public/Get-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 b/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 index a1af8f5..e0b8615 100644 --- a/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerEventLog.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerEventLog.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerGroup.Tests.ps1 index 2e0c553..e439a46 100644 --- a/Tests/Public/Get-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerId.Tests.ps1 b/Tests/Public/Get-TeamViewerId.Tests.ps1 index 2e92e6e..519c360 100644 --- a/Tests/Public/Get-TeamViewerId.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerId.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerId.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerId.ps1" - . "$PSScriptRoot/../../TeamViewerPS/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-ItemPropertyValue { 123456 } } diff --git a/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 b/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 new file mode 100644 index 0000000..b684fb2 --- /dev/null +++ b/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 @@ -0,0 +1,60 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } +} + +Describe 'Get-TeamViewerInstallationDirectory' { + Context 'Windows' { + BeforeAll { + Mock Get-OperatingSystem { 'Windows' } + Mock Get-TeamViewerRegKeyPath { 'testRegistry' } + Mock Test-Path { $true } + function Get-TestItemValue([object]$obj) { + } + $testItem = [PSCustomObject]@{} + $testItem | Add-Member ` + -MemberType ScriptMethod ` + -Name GetValue ` + -Value { param($obj) Get-TestItemValue @PSBoundParameters } + Mock Get-TestItemValue { 'testPath' } + Mock Get-Item { $testItem } + } + + It 'Should check the registry path and return the installation directory' { + $result = Get-TeamViewerInstallationDirectory + $result | Should -Be 'testPath' + Assert-MockCalled Test-Path -Scope It -Times 1 -ParameterFilter { + $Path -eq 'testRegistry' + } + Assert-MockCalled Get-Item -Scope It -Times 1 -ParameterFilter { + $Path -eq 'testRegistry' + } + Assert-MockCalled Test-Path -Scope It -Times 1 -ParameterFilter { + $Path -eq 'testPath/TeamViewer.exe' + } + } + + It 'Should return null if registry path does not exist' { + Mock Test-Path -ParameterFilter { $Path -eq 'testRegistry' } { $false } + $result = Get-TeamViewerInstallationDirectory + $result | Should -BeNull + } + } + + Context 'Linux' { + BeforeAll { + Mock Get-OperatingSystem { 'Linux' } + Mock Test-Path { $true } + } + + It 'Should return the Linux installation directory' { + $result = Get-TeamViewerInstallationDirectory + $result | Should -Be '/opt/teamviewer/tv_bin/' + Assert-MockCalled Test-Path -Scope It -Times 1 -ParameterFilter { + $Path -eq '/opt/teamviewer/tv_bin/TeamViewer' + } + } + } + +} diff --git a/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 b/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 new file mode 100644 index 0000000..191c45b --- /dev/null +++ b/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + Mock Get-TSCSearchDirectory { + @{ + 'TestFolder1' = @('C:\Logs\TestFolder1') + 'TestFolder2' = @('C:\Logs\TestFolder2') + } + } + Mock Test-Path { $true } + Mock Get-ChildItem { + [PSCustomObject]@{ Name = 'file1.log'; FullName = 'C:\Logs\TestFolder1\file1.log' }, + [PSCustomObject]@{ Name = 'file2.log'; FullName = 'C:\Logs\TestFolder2\file2.log' } + } + +} + +Describe 'Get-TeamViewerLogFilePath function' { + Context 'When TeamViewer is not installed' { + BeforeAll { + Mock Test-TeamViewerInstallation { return $false } + Mock Write-Error { return } + } + + It 'Should write an error message' { + Mock -CommandName 'Write-Error' -MockWith { $null } + Get-TeamViewerLogFilePath + Assert-MockCalled -CommandName 'Write-Error' -Exactly -Times 1 + } + } +} + + + diff --git a/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 index 9aa85c9..1058365 100644 --- a/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 index c5da68e..09ee3ad 100644 --- a/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 b/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 index c7cc18e..97d250c 100644 --- a/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerManagementId.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManagementId.ps1" - . "$PSScriptRoot/../../TeamViewerPS/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testManagementId = New-Guid $null = $testManagementId diff --git a/Tests/Public/Get-TeamViewerManager.Tests.ps1 b/Tests/Public/Get-TeamViewerManager.Tests.ps1 index 4639666..69a3226 100644 --- a/Tests/Public/Get-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerManager.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 b/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 index 6d89619..61bca1b 100644 --- a/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerPolicy.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 new file mode 100644 index 0000000..8622899 --- /dev/null +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + Mock Get-TeamViewerApiUri { '//unit.test' } + $Assigned = @('u201', 'u202') + Mock Invoke-TeamViewerRestMethod { @{ + ContinuationToken = $null + AssignedToUsers = $Assigned + } } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testUserRoleId = '72abbedc-9853-4fc8-9d28-fa35e207b048' + $null = $testUserRoleId +} + +Describe 'Get-TeamViewerRoleAssignmentToAccount' { + Context 'When retrieving role assignments' { + It 'Should call the correct API endpoint' { + Get-TeamViewerRoleAssignmentToAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/userroles/assignments/account?userRoleId=$testUserRoleId" -And ` + $Method -eq 'Get' + } + } + + It 'Should return assigned users' { + $result = Get-TeamViewerRoleAssignmentToAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId + $result | Should -HaveCount 2 + } + + } +} diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 new file mode 100644 index 0000000..e13febb --- /dev/null +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + Mock Get-TeamViewerApiUri { '//unit.test' } + $Assigned = @('1001', '1002') + Mock Invoke-TeamViewerRestMethod { @{ + ContinuationToken = $null + AssignedToGroups = $Assigned + } } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testUserRoleId = '72abbedc-9853-4fc8-9d28-fa35e207b048' + $null = $testUserRoleId +} + +Describe 'Get-TeamViewerRoleAssignmentTouserGroup' { + Context 'When retrieving role assignments' { + It 'Should call the correct API endpoint' { + Get-TeamViewerRoleAssignmentToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/userroles/assignments/usergroups?userRoleId=$testUserRoleId" -And ` + $Method -eq 'Get' + } + } + + It 'Should return assigned groups' { + $result = Get-TeamViewerRoleAssignmentToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId + $result | Should -HaveCount 2 + } + + } +} diff --git a/Tests/Public/Get-TeamViewerService.Tests.ps1 b/Tests/Public/Get-TeamViewerService.Tests.ps1 index b06ec74..1ab2467 100644 --- a/Tests/Public/Get-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerService.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Get-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 b/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 index c70f71d..18509fe 100644 --- a/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerSsoDomain.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 b/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 index b5785cc..778c89d 100644 --- a/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerSsoExclusion.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUser.Tests.ps1 b/Tests/Public/Get-TeamViewerUser.Tests.ps1 index 4d61ccb..03aace6 100644 --- a/Tests/Public/Get-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerUser.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 index 79616c0..ac34349 100644 --- a/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerUserGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 index 18b76cb..622e8d3 100644 --- a/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerUserGroupMember.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 new file mode 100644 index 0000000..39979ce --- /dev/null +++ b/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 @@ -0,0 +1,70 @@ + +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { @{ + Roles = @( + @{ id = 'a9c9435d-8544-4e6a-9830-9337078c9aab'; name = 'Role 1'; }, + @{ id = 'e1631449-6321-4a58-920c-5440029b092e'; name = 'Role 2'; } + ) + } + } +} + +Describe 'Get-TeamViewerUserRole' { + + It 'Should call the correct API endpoint to list roles' { + Get-TeamViewerUserRole -ApiToken $testApiToken + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles' -And ` + $Method -eq 'Get' } + } + + It 'Should convert input object to TeamViewerPS.UserRole' { + $inputObject = @{ + id = 'a9c9435d-8544-4e6a-9830-9337078c9aab' + name = 'Role 1' + Permissions = @{ + AllowGroupSharing = $true + ManageAdmins = $false + ManageUsers = $true + ModifyConnections = $true + } + } | ConvertTo-Json + + $result = $inputObject | ConvertFrom-Json | ConvertTo-TeamViewerUserRole + + $result | Should -BeOfType [PSCustomObject] + $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.UserRole' + $result.RoleName | Should -Be 'Role 1' + $result.RoleID | Should -Be 'a9c9435d-8544-4e6a-9830-9337078c9aab' + $result.AllowGroupSharing | Should -Be $true + $result.ManageAdmins | Should -Be $false + $result.ManageUsers | Should -Be $true + $result.ModifyConnections | Should -Be $true + } + + It 'Should call the correct API endpoint for assigned users' { + Get-TeamViewerUserRole -ApiToken $testApiToken + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles' -And ` + $Method -eq 'Get' } + } + + It 'Should return Role objects' { + $result = Get-TeamViewerUserRole -ApiToken $testApiToken + $result | Should -HaveCount 2 + $result[0].PSObject.TypeNames | Should -Contain 'TeamViewerPS.UserRole' + } +} diff --git a/Tests/Public/Get-TeamViewerVersion.Tests.ps1 b/Tests/Public/Get-TeamViewerVersion.Tests.ps1 index fa60967..add13b3 100644 --- a/Tests/Public/Get-TeamViewerVersion.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerVersion.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerVersion.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerVersion.ps1" - . "$PSScriptRoot/../../TeamViewerPS/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-ItemPropertyValue { '15.10.0' } diff --git a/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 b/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 index 42b59b1..be7ad54 100644 --- a/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 +++ b/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Invoke-TeamViewerPing.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerContact.Tests.ps1 b/Tests/Public/New-TeamViewerContact.Tests.ps1 index 93c5848..92de509 100644 --- a/Tests/Public/New-TeamViewerContact.Tests.ps1 +++ b/Tests/Public/New-TeamViewerContact.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerContact.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerContact.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerDevice.Tests.ps1 b/Tests/Public/New-TeamViewerDevice.Tests.ps1 index 4fed522..055aa1b 100644 --- a/Tests/Public/New-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/New-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerGroup.Tests.ps1 b/Tests/Public/New-TeamViewerGroup.Tests.ps1 index b5639de..adc594f 100644 --- a/Tests/Public/New-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/New-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 index eca84e0..51f4a77 100644 --- a/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerPolicy.Tests.ps1 b/Tests/Public/New-TeamViewerPolicy.Tests.ps1 index e7acbed..8ca9745 100644 --- a/Tests/Public/New-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/New-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerPolicy.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerUser.Tests.ps1 b/Tests/Public/New-TeamViewerUser.Tests.ps1 index fa1f082..e323143 100644 --- a/Tests/Public/New-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/New-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerUser.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 index 14a6d8d..2ee4b6d 100644 --- a/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/New-TeamViewerUserGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerUserRole.tests.ps1 b/Tests/Public/New-TeamViewerUserRole.tests.ps1 new file mode 100644 index 0000000..ea41399 --- /dev/null +++ b/Tests/Public/New-TeamViewerUserRole.tests.ps1 @@ -0,0 +1,63 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerUserRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $mockArgs = @{} + $testUserRoleName = 'Test Role' + $testPermissions = 'AllowGroupSharing', 'AssignBackupPolicies' + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { + $mockArgs.Body = $Body + @{ + Role = @{ + Name = $testUserRoleName + Id = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + Permissions = $testPermissions + + } + } + } +} + +Describe 'New-TeamViewerUserRole' { + It 'Should call the correct API endpoint' { + New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles' -And ` + $Method -eq 'Post' + } + } + + It 'Should include the given name in the request' { + New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName + + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.Name | Should -Be $testUserRoleName + } + + It 'Should include the given permissions in the request' { + New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions + + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.Permissions | Should -Be $testPermissions + } + + It 'Should return a UserRole object' { + $result = New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions + $result | Should -Not -BeNullOrEmpty + $result | Should -BeOfType [PSObject] + $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.UserRole' + $result.RoleName | Should -Be $testUserRoleName + foreach ($Rule in $result.Permissions) { + $result.Permissions.$Rule | Should -Be $testPermissions + } + } +} diff --git a/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 b/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 index 7185679..a7094fc 100644 --- a/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Publish-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Publish-TeamViewerGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 b/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 new file mode 100644 index 0000000..6e71775 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 @@ -0,0 +1,49 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerVersion.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } +} +Describe 'Remove-TeamViewerAssignment' { + Context 'Windows' { + BeforeAll { + # Testing independent behavior using mocked dependencies + Mock Get-TeamViewerInstallationDirectory { 'testPath' } + Mock Get-TeamViewerVersion { '15.50' } + Mock Test-TeamViewerInstallation { $true } + Mock Set-Location {} + Mock Start-Process { + $process = New-Object PSObject -Property @{ + ExitCode = 0 + } + $process + } + Mock Resolve-AssignmentErrorCode {} + } + + It 'Should set the location to the installation directory' { + Remove-TeamViewerAssignment + Assert-MockCalled Set-Location -Scope It -Times 1 -ParameterFilter { + $Path -eq 'testPath' + } + } + + + It 'Should call TeamViewer.exe unassignment' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'unassign' } + Remove-TeamViewerAssignment + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should restore the current directory after calling cmd.exe' { + Mock cmd.exe {} + $currentDirectory = Get-Location + Remove-TeamViewerAssignment + Assert-MockCalled Set-Location -Scope It -Times 1 -ParameterFilter { + $Path -eq $currentDirectory + } + } + } +} diff --git a/Tests/Public/Remove-TeamViewerContact.Tests.ps1 b/Tests/Public/Remove-TeamViewerContact.Tests.ps1 index cf4185e..92586de 100644 --- a/Tests/Public/Remove-TeamViewerContact.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerContact.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerContact.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerContact.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 b/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 new file mode 100644 index 0000000..f09c30d --- /dev/null +++ b/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 @@ -0,0 +1,51 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } +} + +Describe 'Remove-TeamViewerCustomization' { + Context 'When TeamViewer is installed' { + BeforeAll { + Mock Test-TeamViewerInstallation { $true } + Mock Get-TeamViewerInstallationDirectory { 'testpath' } + Mock Set-Location + Mock Start-Process { + $process = New-Object PSObject -Property @{ + ExitCode = 0 + } + $process + } + Mock Resolve-CustomizationErrorCode {} + } + + It 'Should call TeamViewer.exe customize --remove' { + Mock Start-Process -ParameterFilter { $_.FilePath -eq 'TeamViewer.exe' -and $_.ArgumentList -eq 'customize --remove"' } + Remove-TeamViewerCustomization + Assert-MockCalled Start-Process -Scope It -Times 1 + } + + It 'Should resolve the customization error code' { + Mock Resolve-CustomizationErrorCode {} + Remove-TeamViewerCustomization + Assert-MockCalled Resolve-CustomizationErrorCode -Scope It -Times 1 + } + } + + Context 'When TeamViewer is not installed' { + BeforeAll { + Mock Test-TeamViewerInstallation { $false } + Mock Write-Error {} + Mock Start-Process {} + } + + It 'Should write an error message' { + Mock Write-Error -ParameterFilter { $_ -eq 'TeamViewer is not installed' } + Remove-TeamViewerCustomization + Assert-MockCalled Start-Process -Scope It -Times 0 + Assert-MockCalled Write-Error -Scope It -Times 1 + } + } +} diff --git a/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 index 4a24f6d..da9e90e 100644 --- a/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 index 54d171b..fa50ebd 100644 --- a/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 index 5781c84..ada1a56 100644 --- a/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 index 10571a2..424cd82 100644 --- a/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 index 487e2c8..078a111 100644 --- a/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManager.Tests.ps1 b/Tests/Public/Remove-TeamViewerManager.Tests.ps1 index 2b90adc..4fc7af4 100644 --- a/Tests/Public/Remove-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerManager.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 b/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 new file mode 100644 index 0000000..674b376 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 @@ -0,0 +1,28 @@ + +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + Mock -CommandName 'Remove-TeamViewerPSProxy' -MockWith { + $global:TeamViewerProxyUriSet = $null + $global:TeamViewerProxyUriSet | Out-Null + $global:TeamViewerProxyUriRemoved = $true + $global:TeamViewerProxyUriRemoved | Out-Null + [Environment]::SetEnvironmentVariable('TVProxyUri', '', 'User') + } +} + +Describe "Remove-TeamViewerPSProxy" { + Context "When removing the proxy URI" { + It "Should set the global variable TeamViewerProxyUriRemoved to true" { + Remove-TeamViewerPSProxy + $global:TeamViewerProxyUriRemoved | Should -Be $true + } + + It "Should remove the environment variable TeamViewerProxyUri" { + Remove-TeamViewerPSProxy + [Environment]::GetEnvironmentVariable("TVProxyUri", "User") | Should -BeNullOrEmpty + } + } +} diff --git a/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 b/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 index c01638b..722e4c2 100644 --- a/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerPolicy.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 index 4f87cdb..049729e 100644 --- a/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1" - . "$PSScriptRoot/../../TeamViewerPS/TeamViewerPS.Types.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1" + . "$PSScriptRoot/../../docs/TeamViewerPS.Types.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} @@ -52,4 +52,3 @@ Describe 'Remove-TeamViewerPolicyFromManagedDevice' { -Device $testDeviceId -PolicyType 2 } | Should -Throw } } - diff --git a/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 b/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 new file mode 100644 index 0000000..dbf9414 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 @@ -0,0 +1,60 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testAccount = @('u123', 'u124') + $null = $testAccount + $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testUserRoleId + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body + @{ + UserIds = @($testAccount) + UserRoleId = $testUserRoleId + } + } +} +Describe 'Remove-TeamViewerRoleFromAccount' { + + It 'Should call the correct API endpoint' { + Remove-TeamViewerRoleFromAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles/unassign/account' -And ` + $Method -eq 'Post' + } + } + + It 'Should unassign the given account from the user role' { + Remove-TeamViewerRoleFromAccount ` + -ApiToken $testApiToken ` + -UserRoleId $testUserRoleId ` + -Accounts $testAccount + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.UserIds | Should -HaveCount 2 + foreach ($id in $testAccount) { + $body.UserIds | Should -Contain $id + } + $body.UserRoleId | Should -Be $testUserRoleId + } + + It 'Should accept pipeline input' { + $testAccount | Remove-TeamViewerRoleFromAccount ` + -ApiToken $testApiToken ` + -UserRoleId $testUserRoleId + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.UserIds | Should -HaveCount 2 + foreach ($id in $testAccount) { + $body.UserIds | Should -Contain $id + } + $body.UserRoleId | Should -Be $testUserRoleId + } +} diff --git a/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 new file mode 100644 index 0000000..750e747 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testUserGroup = 1234 + $null = $testUserGroup + + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body + @{ + UserGroupId = $testUserGroup + } + } +} +Describe 'Remove-TeamViewerRoleFromUserGroup' { + + It 'Should call the correct API endpoint' { + Remove-TeamViewerRoleFromUserGroup -ApiToken $testApiToken -UserGroup $testUserGroup + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles/unassign/usergroup' -And ` + $Method -eq 'Post' + } + } + + It 'Should unassign the given user group from the user role' { + Remove-TeamViewerRoleFromUserGroup ` + -ApiToken $testApiToken ` + -UserGroup $testUserGroup + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.UserGroupId | Should -HaveCount 1 + $body.UserGroupId | Should -Be $testUserGroup + } +} diff --git a/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 b/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 index 17704b8..1054256 100644 --- a/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerSsoExclusion.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerUser.Tests.ps1 b/Tests/Public/Remove-TeamViewerUser.Tests.ps1 index 78f6038..fc2ca78 100644 --- a/Tests/Public/Remove-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerUser.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 index 8dbe921..b282c0c 100644 --- a/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerUserGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 index dfe1add..e0d28e4 100644 --- a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 @@ -1,9 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1" - - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } - $testApiToken = [securestring]@{} $null = $testApiToken $testMembers = @(123, 456, 789) diff --git a/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 new file mode 100644 index 0000000..3694839 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 @@ -0,0 +1,37 @@ + +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testUserRoleId = '2bcf19dc-d5a9-4d25-952e-7cbb21762c9a' + $null = $testUserRoleId + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod {} +} +Describe 'Remove-TeamViewerUserRole' { + It 'Should call the correct API endpoint' { + Remove-TeamViewerUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/userroles?userRoleId=$testUserRoleId" -And ` + $Method -eq 'Delete' + } + } + + It 'Should handle domain object as input' { + $testUserRole = @{Id = $testUserRoleId; Name = 'test user role' } | ConvertTo-TeamViewerUserRole + Remove-TeamViewerUserRole -ApiToken $testApiToken -UserRoleId $testUserRole.RoleID + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/userroles?userRoleId=$testUserRoleId" -And ` + $Method -eq 'Delete' + } + } +} diff --git a/Tests/Public/Restart-TeamViewerService.Tests.ps1 b/Tests/Public/Restart-TeamViewerService.Tests.ps1 index 65cd78e..8bc37b8 100644 --- a/Tests/Public/Restart-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Restart-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Restart-TeamViewerService.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Restart-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Restart-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Set-TeamViewerAccount.Tests.ps1 b/Tests/Public/Set-TeamViewerAccount.Tests.ps1 index f86dfb6..78e7bc1 100644 --- a/Tests/Public/Set-TeamViewerAccount.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerAccount.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerAccount.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerDevice.Tests.ps1 b/Tests/Public/Set-TeamViewerDevice.Tests.ps1 index a291dae..8bdfadf 100644 --- a/Tests/Public/Set-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerGroup.Tests.ps1 index fc7496f..04c8b76 100644 --- a/Tests/Public/Set-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 index 3936d3a..697ad21 100644 --- a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 index 5f12d7f..df73864 100644 --- a/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerManager.Tests.ps1 b/Tests/Public/Set-TeamViewerManager.Tests.ps1 index b9e0d07..e600144 100644 --- a/Tests/Public/Set-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerManager.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 b/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 new file mode 100644 index 0000000..9628118 --- /dev/null +++ b/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 @@ -0,0 +1,50 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ForEach-Object { . $_.FullName } + + Mock -CommandName 'Set-TeamViewerPSProxy' -MockWith { + param ( + [Parameter(Mandatory = $true)] + [Uri] + $ProxyUri + ) + + $global:TeamViewerProxyUriSet = $ProxyUri + $global:TeamViewerProxyUriRemoved = $false + $global:TeamViewerProxyUriRemoved | Out-Null + + [Environment]::SetEnvironmentVariable('TVProxyUri', $ProxyUri, 'User') + } + + Mock -CommandName 'Remove-TeamViewerPSProxy' -MockWith { + $global:TeamViewerProxyUriSet = $null + $global:TeamViewerProxyUriSet | Out-Null + $global:TeamViewerProxyUriRemoved = $true + $global:TeamViewerProxyUriRemoved | Out-Null + [Environment]::SetEnvironmentVariable('TVProxyUri', '', 'User') + } +} + +Describe 'Set-TeamViewerPSProxy' { + Context 'When setting the proxy URI' { + It 'Should set the global variable TeamViewerProxyUriSet' { + $expectedProxyUri = 'http://example.com/proxy' + Set-TeamViewerPSProxy -ProxyUri $expectedProxyUri + $global:TeamViewerProxyUriSet | Should -Be $expectedProxyUri + } + + It 'Should set the environment variable TeamViewerProxyUri' { + $expectedProxyUri = 'http://example.com/proxy' + Set-TeamViewerPSProxy -ProxyUri $expectedProxyUri + [Environment]::GetEnvironmentVariable('TVProxyUri', 'User') | Should -Be $expectedProxyUri + } + + It 'Should set the global variable TeamViewerProxyUriRemoved to false' { + $expectedProxyUri = 'http://example.com/proxy' + Set-TeamViewerPSProxy -ProxyUri $expectedProxyUri + $global:TeamViewerProxyUriRemoved | Should -Be $false + Remove-TeamViewerPSProxy + } + } +} diff --git a/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 b/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 index 2968773..d6d810b 100644 --- a/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerPolicy.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerUser.Tests.ps1 b/Tests/Public/Set-TeamViewerUser.Tests.ps1 index 727a144..a1d4a95 100644 --- a/Tests/Public/Set-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerUser.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 index 61e7dd0..868dfd7 100644 --- a/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Set-TeamViewerUserGroup.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 new file mode 100644 index 0000000..de22d5b --- /dev/null +++ b/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 @@ -0,0 +1,73 @@ +BeforeAll { + . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $mockArgs = @{} + $testUserRoleName = 'Test Role' + $null = $testUserRoleName + $testPermissions = 'AllowGroupSharing', 'AssignBackupPolicies' + $null = $testPermissions + $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testUserRoleId + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { + $mockArgs.Body = $Body + @{ + Name = $testUserRoleName + Permissions = @($testPermissions) + UserRoleId = $testUserRoleId + + } + } +} + +Describe 'Set-TeamViewerUserRole' { + It 'Should call the correct API endpoint' { + Set-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles' -And ` + $Method -eq 'Put' + } + } + + It 'Should include the given name in the request' { + Set-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId + + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.Name | Should -Be $testUserRoleName + } + + It 'Should include the given permissions in the request' { + Set-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions -UserRoleId $testUserRoleId + + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.Permissions | Should -Be $testPermissions + } + + # It 'Should return a UserRole object' { + #Request doesn't return a response body + # } + + It 'Should change user role properties' { + $TestNameChange = 'Test1234' + $testPermissionsChange = 'ModifyConnections' + Set-TeamViewerUserRole ` + -ApiToken $testApiToken ` + -Name $TestNameChange ` + -Permissions $testPermissionsChange ` + -UserRoleId $testUserRoleId + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.Name | Should -Be 'Test1234' + $body.Permissions | Should -Be 'ModifyConnections' + + } +} diff --git a/Tests/Public/Start-TeamViewerService.Tests.ps1 b/Tests/Public/Start-TeamViewerService.Tests.ps1 index 84d747e..31d450e 100644 --- a/Tests/Public/Start-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Start-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Start-TeamViewerService.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Start-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Start-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Stop-TeamViewerService.Tests.ps1 b/Tests/Public/Stop-TeamViewerService.Tests.ps1 index 31ba6f6..f13eb36 100644 --- a/Tests/Public/Stop-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Stop-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Stop-TeamViewerService.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Stop-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Stop-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 b/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 index 8eb1071..8de6069 100644 --- a/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 +++ b/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Test-TeamViewerConnectivity.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerConnectivity.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } Mock Test-TcpConnection { $true } @@ -75,4 +75,4 @@ Describe 'Test-TeamViewerConnectivity' { $result | Should -BeFalse $result | Should -BeOfType [bool] } -} \ No newline at end of file +} diff --git a/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 b/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 index 72c5a5b..59ddedb 100644 --- a/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 +++ b/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 @@ -1,56 +1,31 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Get-TeamViewerId.ps1" - - . "$PSScriptRoot/../../TeamViewerPS/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } } Describe 'Test-TeamViewerInstallation' { - Context 'Windows' { + Context 'TeamViewer installed' { BeforeAll { - function Get-TestItemValue([object]$obj) {} - Mock Get-TestItemValue { 'testPath' } - $testItem = [PSCustomObject]@{} - $testItem | Add-Member ` - -MemberType ScriptMethod ` - -Name GetValue ` - -Value { param($obj) Get-TestItemValue @PSBoundParameters } - Mock Get-OperatingSystem { 'Windows' } - Mock Get-TeamViewerRegKeyPath { 'testRegistry' } - Mock Get-Item { $testItem } - Mock Test-Path { $true } + Mock Get-TeamViewerInstallationDirectory { 'C:\Program Files\TeamViewer' } } - It 'Should check the registry path and look for TeamViewer.exe' { - Test-TeamViewerInstallation | Should -BeTrue - Assert-MockCalled Test-Path -Scope It -Times 1 -ParameterFilter { - $Path -eq 'testRegistry' - } - Assert-MockCalled Test-Path -Scope It -Times 1 -ParameterFilter { - $Path -eq 'testPath/TeamViewer.exe' - } - Assert-MockCalled Get-Item -Scope It -Times 1 -ParameterFilter { - $Path -eq 'testRegistry' - } - Assert-MockCalled Get-TestItemValue -Scope It -Times 1 -ParameterFilter { - $obj -eq 'InstallationDirectory' - } + It 'Should return true if TeamViewer is installed' { + $result = Test-TeamViewerInstallation + $result | Should -Be $true } + } - It 'Should return false if registry path does not exist' { - Mock Test-Path -ParameterFilter { $Path -eq 'testRegistry' } { $false } - Test-TeamViewerInstallation | Should -BeFalse + Context 'TeamViewer not installed' { + BeforeAll { + Mock Get-TeamViewerInstallationDirectory { $null } } - It 'Should return false if TeamViewer.exe does not exist' { - Mock Test-Path -ParameterFilter { $Path -eq 'testPath/TeamViewer.exe' } { $false } - Test-TeamViewerInstallation | Should -BeFalse + It 'Should return false if TeamViewer is not installed' { + $result = Test-TeamViewerInstallation + $result | Should -Be $false } } - - It 'Should return false on unsupported platforms' { - Mock Get-OperatingSystem { 'SomeOtherPlatform' } - Test-TeamViewerInstallation | Should -BeFalse - } } + diff --git a/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 b/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 index 80eb438..b9a96b7 100644 --- a/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../TeamViewerPS/Public/Unpublish-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../TeamViewerPS/Private/*.ps1") | ` + . "$PSScriptRoot/../../docs/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/docs/Cmdlets/Private/Add-Registry.ps1 b/docs/Cmdlets/Private/Add-Registry.ps1 new file mode 100644 index 0000000..bab75a6 --- /dev/null +++ b/docs/Cmdlets/Private/Add-Registry.ps1 @@ -0,0 +1,40 @@ +function Add-Registry { + param ( + [Microsoft.Win32.RegistryKey]$RegKey, + [string]$Program + ) + + #CustomObject including all information for each registry and sub keys + $retRegKey = [PSCustomObject]@{ + Program = $Program + RegistryPath = $RegKey.Name + Entries = @() + } + Write-Output "Collecting registry data $($retRegKey.RegistryPath)" + foreach ($valueName in $RegKey.GetValueNames()) { + $value = $RegKey.GetValue($valueName) + $type, $value = Get-TypeAndValueOfRegistryValue -RegKey $RegKey -ValueName $valueName + $blackList = @('BuddyLoginTokenAES', 'BuddyLoginTokenSecretAES', 'Certificate', 'CertificateKey', 'CertificateKeyProtected', + 'MultiPwdMgmtPwdData', 'PermanentPassword', 'PK', 'SecurityPasswordAES', 'SK', 'SRPPasswordMachineIdentifier') + foreach ($blackListValue in $blackList) { + if ($valueName -eq $blackListValue) { + $value = '___PRIVATE___' + } + } + $entry = [PSCustomObject]@{ + Name = $valueName + Value = $value + Type = $type + } + $retRegKey.Entries += $entry + } + + foreach ($subKeyName in $RegKey.GetSubKeyNames()) { + $subKey = $RegKey.OpenSubKey($subKeyName) + Add-Registry -RegKey $subKey -Program $subKeyName + } + #Adding CustomObject to array declared in Get-RegistryPaths + $AllTVRegistryData.Add($retRegKey) | Out-Null +} + + diff --git a/TeamViewerPS/Private/ConvertTo-DateTime.ps1 b/docs/Cmdlets/Private/ConvertTo-DateTime.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-DateTime.ps1 rename to docs/Cmdlets/Private/ConvertTo-DateTime.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-ErrorRecord.ps1 b/docs/Cmdlets/Private/ConvertTo-ErrorRecord.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-ErrorRecord.ps1 rename to docs/Cmdlets/Private/ConvertTo-ErrorRecord.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerAccount.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerAccount.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerAccount.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerAccount.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerAuditEvent.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerAuditEvent.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerAuditEvent.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerAuditEvent.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerConnectionReport.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerConnectionReport.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerConnectionReport.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerConnectionReport.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerContact.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerContact.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerContact.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerContact.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerDevice.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerDevice.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerDevice.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerDevice.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerGroup.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerGroup.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerGroupShare.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerGroupShare.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerGroupShare.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerGroupShare.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerManagedDevice.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerManagedDevice.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerManagedDevice.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerManagedDevice.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerManagedGroup.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerManagedGroup.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerManagedGroup.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerManagedGroup.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerManager.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerManager.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerManager.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerManager.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerPolicy.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerPolicy.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerPolicy.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerPolicy.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerRestError.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerRestError.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerRestError.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerRestError.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 new file mode 100644 index 0000000..a0b7667 --- /dev/null +++ b/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 @@ -0,0 +1,13 @@ +function ConvertTo-TeamViewerRoleAssignedUser { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{AssignedUsers = ($InputObject.trim('u'))} + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUser') + Write-Output $result + } +} diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 new file mode 100644 index 0000000..06e0658 --- /dev/null +++ b/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 @@ -0,0 +1,13 @@ +function ConvertTo-TeamViewerRoleAssignedUserGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{AssignedGroups = ($InputObject)} + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUserGroup') + Write-Output $result + } +} diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerSsoDomain.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerSsoDomain.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerSsoDomain.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerSsoDomain.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerUser.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 similarity index 100% rename from TeamViewerPS/Private/ConvertTo-TeamViewerUser.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerUserGroup.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 similarity index 96% rename from TeamViewerPS/Private/ConvertTo-TeamViewerUserGroup.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 index 7ed14d5..c2272d2 100644 --- a/TeamViewerPS/Private/ConvertTo-TeamViewerUserGroup.ps1 +++ b/docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 @@ -1,16 +1,16 @@ -function ConvertTo-TeamViewerUserGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [UInt64]$InputObject.id - Name = $InputObject.name - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroup') - Write-Output $result - } -} +function ConvertTo-TeamViewerUserGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [UInt64]$InputObject.id + Name = $InputObject.name + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroup') + Write-Output $result + } +} diff --git a/TeamViewerPS/Private/ConvertTo-TeamViewerUserGroupMember.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 similarity index 96% rename from TeamViewerPS/Private/ConvertTo-TeamViewerUserGroupMember.ps1 rename to docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 index e9d3ab2..8c16f11 100644 --- a/TeamViewerPS/Private/ConvertTo-TeamViewerUserGroupMember.ps1 +++ b/docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 @@ -1,16 +1,16 @@ -function ConvertTo-TeamViewerUserGroupMember { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - AccountId = [int]$InputObject.accountId - Name = $InputObject.name - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroupMember') - Write-Output $result - } -} +function ConvertTo-TeamViewerUserGroupMember { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + AccountId = [int]$InputObject.accountId + Name = $InputObject.name + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroupMember') + Write-Output $result + } +} diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 b/docs/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 new file mode 100644 index 0000000..3ecf278 --- /dev/null +++ b/docs/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 @@ -0,0 +1,25 @@ +function ConvertTo-TeamViewerUserRole { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + RoleName = $InputObject.Name + RoleID = $InputObject.Id + } + if ($InputObject.Permissions) { + foreach ($permission in $InputObject.Permissions.PSObject.Properties) { + $properties[$permission.Name] = $permission.Value + } + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserRole') + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "[$($this.RoleName)] [$($this.RoleID)] $($this.Permissions))" + } + Write-Output $result + } +} + diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 new file mode 100644 index 0000000..5312ba5 --- /dev/null +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -0,0 +1,12 @@ +function Get-ClientId { + if (Test-Path -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer') { + $mainKey = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' + $id = [int]$mainKey.ClientID + } + elseif (Test-Path -Path 'HKLM:\Software\TeamViewer') { + $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' + $id = [int]$mainKey.ClientID + } + + return $id +} diff --git a/docs/Cmdlets/Private/Get-HostFile.ps1 b/docs/Cmdlets/Private/Get-HostFile.ps1 new file mode 100644 index 0000000..e36a499 --- /dev/null +++ b/docs/Cmdlets/Private/Get-HostFile.ps1 @@ -0,0 +1,15 @@ +function Get-HostFile { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + process { + $regPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' + $regKey = Get-ItemProperty -Path $regPath + $hostsPath = Join-Path -Path $regKey.DataBasePath -ChildPath 'hosts' + $hostsFile = Get-Content -Path $hostsPath + $hostsFile | Out-File -FilePath "$OutputPath\Data\hosts.txt" + Write-Output "hosts file collected and saved to $OutputPath\Data\hosts.txt" + } +} diff --git a/docs/Cmdlets/Private/Get-InstalledSoftware.ps1 b/docs/Cmdlets/Private/Get-InstalledSoftware.ps1 new file mode 100644 index 0000000..604cd3a --- /dev/null +++ b/docs/Cmdlets/Private/Get-InstalledSoftware.ps1 @@ -0,0 +1,38 @@ +function Get-InstalledSoftware { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $regUninstall = @{ + InstalledSoftware32 = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' + InstalledSoftware64 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' + } + } + Process { + foreach ($Name in $regUninstall.keys) { + $regKeys = $regUninstall[$Name] + $regKey = Get-ItemProperty -Path "$regKeys\*" + if ($null -ne $regKey) { + $subKeys = $regKey.PSChildName + if ($null -ne $subKeys) { + $installedPrograms = @() + foreach ($subKey in $subKeys) { + $tmpSubkey = Get-ItemProperty -Path "$regKeys\$subKey" + $programmName = $tmpSubkey.DisplayName + $displayVersion = $tmpSubkey.DisplayVersion + if ($null -ne $programmName) { + $tmpSoftwareData = "$programmName | $displayVersion" + $installedPrograms += $tmpSoftwareData + } + } + } + $installedPrograms | Sort-Object | Out-File -FilePath "$OutputPath\Data\$Name.txt" + Write-Output "$Name collected and saved to $OutputPath\Data\$Name.txt" + } + } + } +} + + diff --git a/docs/Cmdlets/Private/Get-IpConfig.ps1 b/docs/Cmdlets/Private/Get-IpConfig.ps1 new file mode 100644 index 0000000..4bd3bdf --- /dev/null +++ b/docs/Cmdlets/Private/Get-IpConfig.ps1 @@ -0,0 +1,16 @@ +function Get-IpConfig { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Process { + try { + ipconfig /all | Out-File -FilePath "$OutputPath\Data\ipconfig.txt" -Encoding utf8 + Write-Output "ipconfig data collected and saved to $OutputPath\Data\ipconfig.txt" + } + catch { + Write-Error "An error occurred while collecting ipconfig data: $_" + } + } +} diff --git a/docs/Cmdlets/Private/Get-MSInfo32.ps1 b/docs/Cmdlets/Private/Get-MSInfo32.ps1 new file mode 100644 index 0000000..29929c8 --- /dev/null +++ b/docs/Cmdlets/Private/Get-MSInfo32.ps1 @@ -0,0 +1,17 @@ +function Get-MSInfo32 { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Process { + try { + Start-Process -FilePath msinfo32.exe -ArgumentList "/nfo $OutputPath\Data\msinfo32.nfo" -Wait + + Write-Output "msinfo data collected and saved to $OutputPath\Data\msinfo32.nfo" + } + catch { + Write-Error "An error occurred while collecting msinfo data: $_" + } + } +} diff --git a/docs/Cmdlets/Private/Get-NSLookUpData.ps1 b/docs/Cmdlets/Private/Get-NSLookUpData.ps1 new file mode 100644 index 0000000..7838c7f --- /dev/null +++ b/docs/Cmdlets/Private/Get-NSLookUpData.ps1 @@ -0,0 +1,50 @@ +function Get-NSLookUpData { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $Ipv4DnsServer = @($null, 'tv-ns1.teamviewer.com', 'tv-ns2.teamviewer.com', 'tv-ns3.teamviewer.com', + 'tv-ns4.teamviewer.com', 'tv-ns5.teamviewer.com', '8.8.8.8', '1.1.1.1') + $Ipv4DnsName = @( 'master1.teamviewer.com', 'router1.teamviewer.com', 'google.com', + 'login.teamviewer.com', 'www.teamviewer.com') + $output = $null + } + Process { + try { + foreach ($DnsName in $Ipv4DnsName ) { + foreach ($DnsServer in $Ipv4DnsServer) { + Write-Output "Collecting nslookup.exe information from $DnsName $DnsServer. This might take a while" + $output += "nslookup information for: $DnsName $DnsServer `r`n" + $arguments = "-debug ""$DnsName""" + if ($DnsServer) { + $arguments += " ""$DnsServer""" + } + $processInfo = New-Object System.Diagnostics.ProcessStartInfo + $processInfo.FileName = 'nslookup.exe' + $processInfo.Arguments = $arguments + $processInfo.WindowStyle = 'Hidden' + $processInfo.UseShellExecute = $false + $processInfo.RedirectStandardOutput = $true + + $process = [System.Diagnostics.Process]::Start($processInfo) + $output += $process.StandardOutput.ReadToEnd() + $process.WaitForExit(60000) + if (-not $process.HasExited) { + $process.Kill() + continue + } + $output += $process.StandardOutput.ReadToEnd() + } + } + $output | Out-File "$OutputPath\Data\nslookup.txt" + } + + catch { + Write-Error "Error collecting nslookup information: $_" + } + } +} + + diff --git a/TeamViewerPS/Private/Get-OperatingSystem.ps1 b/docs/Cmdlets/Private/Get-OperatingSystem.ps1 similarity index 100% rename from TeamViewerPS/Private/Get-OperatingSystem.ps1 rename to docs/Cmdlets/Private/Get-OperatingSystem.ps1 diff --git a/docs/Cmdlets/Private/Get-RegistryPath.ps1 b/docs/Cmdlets/Private/Get-RegistryPath.ps1 new file mode 100644 index 0000000..74c9782 --- /dev/null +++ b/docs/Cmdlets/Private/Get-RegistryPath.ps1 @@ -0,0 +1,47 @@ +function Get-RegistryPath { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $SearchProgramms = @('TeamViewer', 'Blizz', 'TeamViewerMeeting') + $RegistrySearchPathsLocalMachine = @('SOFTWARE\Wow6432Node', 'SOFTWARE') + $RegistrySearchPathsCurrentUser = @('SOFTWARE') + $AllTVRegistryData = New-Object System.Collections.ArrayList + } + + Process { + foreach ($searchProgramm in $SearchProgramms) { + foreach ($registrySearchPath in $RegistrySearchPathsLocalMachine) { + $regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$registrySearchPath\$searchProgramm", $false) + if ($regKey) { + Add-Registry -RegKey $regKey -Program $searchProgramm + } + } + + foreach ($registrySearchPath in $RegistrySearchPathsCurrentUser) { + $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm", $false) + if ($searchProgramm -eq 'Blizz' -or $searchProgramm -eq 'TeamViewerMeeting') { + $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm\MachineFallback", $false) + } + if ($regKey) { + Add-Registry -RegKey $regKey -Program $searchProgramm + } + } + + $output = "Windows Registry Editor Version 5.00 `r`n" + foreach ($data in $AllTVRegistryData) { + $output += "[$($data.RegistryPath)]`r`n" + foreach ($entry in $data.Entries) { + if ($null -ne $entry.name) { + $output += """$($entry.Name)""" + $entry.Type + $entry.Value + "`r`n" + } + } + $output += "`r`n" + } + $output | Out-File -FilePath "$OutputPath\Data\TeamViewer_Version15\Reg_Version15.txt" + } + } + +} diff --git a/docs/Cmdlets/Private/Get-RouteTable.ps1 b/docs/Cmdlets/Private/Get-RouteTable.ps1 new file mode 100644 index 0000000..caf68cd --- /dev/null +++ b/docs/Cmdlets/Private/Get-RouteTable.ps1 @@ -0,0 +1,24 @@ +function Get-RouteTable { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) +Process{ + try { + $processInfo = New-Object System.Diagnostics.ProcessStartInfo + $processInfo.FileName = 'route.exe' + $processInfo.Arguments = 'print' + $processInfo.WindowStyle = 'Hidden' + $processInfo.UseShellExecute = $false + $processInfo.RedirectStandardOutput = $true + + $process = [System.Diagnostics.Process]::Start($processInfo) + $output = $process.StandardOutput.ReadToEnd() + $output | Out-File "$OutputPath\Data\RouteTable.txt" + } + catch { + Write-Error "An error occurred while collecting RouteTable data: $_" + } +} +} diff --git a/docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 b/docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 new file mode 100644 index 0000000..401aaee --- /dev/null +++ b/docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 @@ -0,0 +1,35 @@ +function Get-TSCDirectoryFile { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + + Process { + $SearchDirectories = Get-TSCSearchDirectory + $TempDirectory = New-Item -Path $OutputPath -Name 'Data' -ItemType Directory -Force + $Endings = @('.log', 'tvinfo.ini', '.mdmp', 'Connections.txt', 'Connections_incoming.txt') + $TmpLogFiles = @() + foreach ($Name in $SearchDirectories.Keys) { + $SearchDirectory = $SearchDirectories[$Name] + foreach ($Folder in $SearchDirectory) { + if (Test-Path -Path $Folder) { + $TempSubdirectory = Join-Path -Path $TempDirectory -ChildPath $Name + New-Item -Path $TempSubdirectory -ItemType Directory -Force | Out-Null + $files = Get-ChildItem -Path $Folder -File -Recurse + foreach ($file in $files) { + foreach ($ending in $Endings) { + if ($file.Name.EndsWith($ending)) { + $tmpLogfilePath = Join-Path -Path $TempSubdirectory -ChildPath $file.Name + Copy-Item -Path $file.FullName -Destination $tmpLogfilePath -Force + $TmpLogFiles += $tmpLogfilePath + Write-Output "Collected log file from $($file.FullName)" + } + } + } + } + } + } + Write-Output 'Files from TeamViewer directories have been collected.' + } +} diff --git a/docs/Cmdlets/Private/Get-TSCSearchDirectory.ps1 b/docs/Cmdlets/Private/Get-TSCSearchDirectory.ps1 new file mode 100644 index 0000000..b855884 --- /dev/null +++ b/docs/Cmdlets/Private/Get-TSCSearchDirectory.ps1 @@ -0,0 +1,14 @@ +function Get-TSCSearchDirectory { + $LocalAppData = [System.Environment]::GetFolderPath('LocalApplicationData') + $RoamingAppData = [System.Environment]::GetFolderPath('ApplicationData') + $TVAppData = Join-Path -Path $LocalAppData.ToString() -ChildPath 'TeamViewer/Logs' + $TVRoamingData = Join-Path -Path $RoamingAppData.ToString() -ChildPath 'TeamViewer' + $InstallationDirectory = Get-TeamViewerInstallationDirectory + + $TSCSearchDirectory = @{ + 'TeamViewer_Version15' = $InstallationDirectory + 'AppData\TeamViewer' = @($TVAppData; $TVRoamingData) + } + + return $TSCSearchDirectory +} diff --git a/docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 b/docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 new file mode 100644 index 0000000..6070e6d --- /dev/null +++ b/docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 @@ -0,0 +1,22 @@ + + +class TeamViewerConfiguration { + [string]$APIUri = 'https://webapi.teamviewer.com/api/v1' + + static [TeamViewerConfiguration] $Instance = $null + + static [TeamViewerConfiguration] GetInstance() { + if (-not [TeamViewerConfiguration]::Instance) { + [TeamViewerConfiguration]::Instance = [TeamViewerConfiguration]::new() + } + + return [TeamViewerConfiguration]::Instance + } +} + +function Get-TeamViewerAPIUri { + $config = [TeamViewerConfiguration]::GetInstance() + return $config.APIUri +} + + diff --git a/TeamViewerPS/Private/Get-TeamViewerLinuxGlobalConfig.ps1 b/docs/Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 similarity index 74% rename from TeamViewerPS/Private/Get-TeamViewerLinuxGlobalConfig.ps1 rename to docs/Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 index 86e32b0..199a0b6 100644 --- a/TeamViewerPS/Private/Get-TeamViewerLinuxGlobalConfig.ps1 +++ b/docs/Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 @@ -8,7 +8,7 @@ function Get-TeamViewerLinuxGlobalConfig { [string] $Name ) - $config = Get-Content $Path | ForEach-Object { + $config = & sudo pwsh -command Get-Content $Path | ForEach-Object { if ($_ -Match '\[(?\w+)\s*\]\s+(?[\w\\]+)\s+=\s*(?.*)$') { $Matches.Remove(0) $entry = [pscustomobject]$Matches @@ -23,7 +23,10 @@ function Get-TeamViewerLinuxGlobalConfig { $entry.EntryValue = [int32]($entry.EntryValue) } 'int64' { - $entry.EntryValue = [int64]($entry.EntryValue) + #In some cases the EntryName DeviceManagement/TransitionNonces is set to entryvalue '0 0 0 0 0' of type int64 + if ($entry.EntryValue -notmatch '0 0 0 0 0') { + $entry.EntryValue = [int64]($entry.EntryValue) + } } } $entry diff --git a/TeamViewerPS/Private/Get-TeamViewerRegKeyPath.ps1 b/docs/Cmdlets/Private/Get-TeamViewerRegKeyPath.ps1 similarity index 100% rename from TeamViewerPS/Private/Get-TeamViewerRegKeyPath.ps1 rename to docs/Cmdlets/Private/Get-TeamViewerRegKeyPath.ps1 diff --git a/TeamViewerPS/Private/Get-TeamViewerServiceName.ps1 b/docs/Cmdlets/Private/Get-TeamViewerServiceName.ps1 similarity index 100% rename from TeamViewerPS/Private/Get-TeamViewerServiceName.ps1 rename to docs/Cmdlets/Private/Get-TeamViewerServiceName.ps1 diff --git a/docs/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 b/docs/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 new file mode 100644 index 0000000..c8b70fe --- /dev/null +++ b/docs/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 @@ -0,0 +1,39 @@ +function Get-TypeAndValueOfRegistryValue { + param ( + [Microsoft.Win32.RegistryKey]$RegKey, + [string]$ValueName + ) + + $valueKind = $RegKey.GetValueKind($ValueName) + $type = $valueKind + + if ($valueKind -eq 'DWord') { + $type = "=dword:" + $value = [Convert]::ToInt32($RegKey.GetValue($ValueName)).ToString('x') + } + elseif ($valueKind -eq 'Binary') { + $type = "=hex:" + $value = ($RegKey.GetValue($ValueName) | ForEach-Object { $_.ToString('x2') }) -join ',' + } + elseif ($valueKind -eq 'String') { + $type = "=" + $value = $RegKey.GetValue($ValueName).ToString() + } + elseif ($valueKind -eq 'MultiString') { + $type = "=hex(7):" + $value += ($RegKey.GetValue($ValueName) | ForEach-Object { + $_.ToCharArray() | ForEach-Object { [Convert]::ToInt32($_).ToString('X') + ',00' } + }) -join ',' + $value += ',00,00,' + if ($value.Length -gt 0) { + $value += '00,00' + } + } + else { + $type = "" + $value = $RegKey.GetValue($ValueName).ToString() + } + + return $type, $value +} + diff --git a/TeamViewerPS/Private/Invoke-ExternalCommand.ps1 b/docs/Cmdlets/Private/Invoke-ExternalCommand.ps1 similarity index 100% rename from TeamViewerPS/Private/Invoke-ExternalCommand.ps1 rename to docs/Cmdlets/Private/Invoke-ExternalCommand.ps1 diff --git a/TeamViewerPS/Private/Invoke-TeamViewerRestMethod.ps1 b/docs/Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 similarity index 75% rename from TeamViewerPS/Private/Invoke-TeamViewerRestMethod.ps1 rename to docs/Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 index 49f8061..ac3192e 100644 --- a/TeamViewerPS/Private/Invoke-TeamViewerRestMethod.ps1 +++ b/docs/Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 @@ -22,17 +22,31 @@ function Invoke-TeamViewerRestMethod { [System.Management.Automation.PSCmdlet] $WriteErrorTo + ) if (-Not $Headers) { $Headers = @{ } - $PSBoundParameters.Add("Headers", $Headers) | Out-Null + $PSBoundParameters.Add('Headers', $Headers) | Out-Null + } + + if ($global:TeamViewerProxyUriSet) { + $Proxy = $global:TeamViewerProxyUriSet + } + elseif ([Environment]::GetEnvironmentVariable('TeamViewerProxyUri') ) { + $Proxy = [Environment]::GetEnvironmentVariable('TeamViewerProxyUri') + if ($global:TeamViewerProxyUriRemoved) { + $Proxy = $null + } + } + If ($Proxy) { + $PSBoundParameters.Add('Proxy', $Proxy) | Out-Null } $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ApiToken) - $Headers["Authorization"] = "Bearer $([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr))" + $Headers['Authorization'] = "Bearer $([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr))" [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - $PSBoundParameters.Remove("ApiToken") | Out-Null - $PSBoundParameters.Remove("WriteErrorTo") | Out-Null + $PSBoundParameters.Remove('ApiToken') | Out-Null + $PSBoundParameters.Remove('WriteErrorTo') | Out-Null $currentTlsSettings = [Net.ServicePointManager]::SecurityProtocol [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 @@ -40,9 +54,11 @@ function Invoke-TeamViewerRestMethod { $currentProgressPreference = $ProgressPreference $ProgressPreference = 'SilentlyContinue' + # Using `Invoke-WebRequest` instead of `Invoke-RestMethod`: # There is a known issue for PUT and DELETE operations to hang on Windows Server 2012. try { + return ((Invoke-WebRequest -UseBasicParsing @PSBoundParameters).Content | ConvertFrom-Json) } catch { diff --git a/docs/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 b/docs/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 new file mode 100644 index 0000000..ab50962 --- /dev/null +++ b/docs/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 @@ -0,0 +1,38 @@ +function Resolve-AssignmentErrorCode { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $exitCode + ) + Begin { + $exitCodeMessages = @{ + 0 = 'Operation successful' + 1 = 'Misspelled or used a wrong command' + 2 = 'Signature verification error' + 3 = 'TeamViewer is not installed' + 4 = 'The assignment configuration could not be verified against the TeamViewer Cloud.Try again later.' + 400 = 'Invalid assignment ID' + 401 = 'TeamViewer service not running' + 402 = 'Service Incompatible Version' + 403 = 'Check your internet connection' + 404 = 'Another assignment process running' + 405 = 'Timeout' + 406 = 'Failed due to unknown reasons' + 407 = 'Access denied. Ensure local administrator rights' + 408 = 'Denied by policy' + } + } + Process { + if ($exitCode) { + if ($exitCodeMessages.ContainsKey($exitCode)) { + Write-Output $exitCodeMessages[$exitCode] + } + else { + Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" + } + } + elseif ($exitCode -eq 0) { + Write-Output $exitCodeMessages[$exitCode] + } + } +} diff --git a/docs/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 b/docs/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 new file mode 100644 index 0000000..d217694 --- /dev/null +++ b/docs/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 @@ -0,0 +1,33 @@ +function Resolve-CustomizationErrorCode { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $exitCode + ) + Begin { + $exitCodeMessages = @{ + 0 = 'Operation successful' + 1 = 'Invalid command line arguments' + 500 = 'An internal error occurred. See TeamViewer log files for more details!' + 501 = 'The current user was denied access' + 502 = 'The download of the custom configuration timed out' + 503 = 'Invalid Module' + 504 = 'Restart of the GUI failed' + 505 = 'Custom configuration failed. See the TeamViewer log files for more details and check if the custom configuration id is still valid.' + 506 = 'Removal of custom configuration failed. See the TeamViewer log files for more details!' + } + } + Process { + if ($exitCode) { + if ($exitCodeMessages.ContainsKey($exitCode)) { + Write-Output $exitCodeMessages[$exitCode] + } + else { + Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" + } + } + elseif ($exitCode -eq 0) { + Write-Output $exitCodeMessages[$exitCode] + } + } +} diff --git a/TeamViewerPS/Private/Resolve-TeamViewerContactId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerContactId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerContactId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerContactId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerDeviceId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerDeviceId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerDeviceId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerDeviceId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerGroupId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerGroupId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerGroupId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerGroupId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerLanguage.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerLanguage.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerLanguage.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerLanguage.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerManagedDeviceId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerManagedDeviceId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerManagedDeviceId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerManagedDeviceId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerManagedGroupId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerManagedGroupId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerManagedGroupId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerManagedGroupId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerManagerId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerManagerId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerManagerId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerManagerId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerPolicyId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerPolicyId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerPolicyId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerPolicyId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerSsoDomainId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerSsoDomainId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerSsoDomainId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerSsoDomainId.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerUserEmail.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerUserEmail.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerUserEmail.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerUserEmail.ps1 diff --git a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 similarity index 97% rename from TeamViewerPS/Private/Resolve-TeamViewerUserGroupId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 index 065662d..0662b96 100644 --- a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupId.ps1 +++ b/docs/Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 @@ -1,21 +1,21 @@ -function Resolve-TeamViewerUserGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserGroup - ) - Process { - if ($UserGroup.PSObject.TypeNames -contains 'TeamViewerPS.UserGroup') { - return [UInt64]$UserGroup.Id - } - elseif ($UserGroup -is [string]) { - return [UInt64]$UserGroup - } - elseif ($UserGroup -is [UInt64] -or $UserGroup -is [Int64] -or $UserGroup -is [int]) { - return [UInt64]$UserGroup - } - else { - throw "Invalid user group identifier '$UserGroup'. Must be either a [TeamViewerPS.UserGroup], [UInt64], [Int64] or [string]." - } - } -} +function Resolve-TeamViewerUserGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserGroup + ) + Process { + if ($UserGroup.PSObject.TypeNames -contains 'TeamViewerPS.UserGroup') { + return [UInt64]$UserGroup.Id + } + elseif ($UserGroup -is [string]) { + return [UInt64]$UserGroup + } + elseif ($UserGroup -is [UInt64] -or $UserGroup -is [Int64] -or $UserGroup -is [int]) { + return [UInt64]$UserGroup + } + else { + throw "Invalid user group identifier '$UserGroup'. Must be either a [TeamViewerPS.UserGroup], [UInt64], [Int64] or [string]." + } + } +} diff --git a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 similarity index 97% rename from TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 index 4d75627..dc3868c 100644 --- a/TeamViewerPS/Private/Resolve-TeamViewerUserGroupMemberId.ps1 +++ b/docs/Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 @@ -1,24 +1,24 @@ -function Resolve-TeamViewerUserGroupMemberMemberId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserGroupMember - ) - Process { - if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { - return $UserGroupMember.AccountId - } - elseif ($UserGroupMember -match 'u[0-9]+') { - return $UserGroupMember - } - elseif ($UserGroupMember -is [string]) { - return [int]$UserGroupMember - } - elseif ($UserGroupMember -is [int]) { - return $UserGroupMember - } - else { - throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." - } - } -} +function Resolve-TeamViewerUserGroupMemberMemberId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserGroupMember + ) + Process { + if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { + return $UserGroupMember.AccountId + } + elseif ($UserGroupMember -match 'u[0-9]+') { + return $UserGroupMember + } + elseif ($UserGroupMember -is [string]) { + return [int]$UserGroupMember + } + elseif ($UserGroupMember -is [int]) { + return $UserGroupMember + } + else { + throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." + } + } +} diff --git a/TeamViewerPS/Private/Resolve-TeamViewerUserId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerUserId.ps1 similarity index 100% rename from TeamViewerPS/Private/Resolve-TeamViewerUserId.ps1 rename to docs/Cmdlets/Private/Resolve-TeamViewerUserId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 b/docs/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 new file mode 100644 index 0000000..7ed22bc --- /dev/null +++ b/docs/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 @@ -0,0 +1,19 @@ + +function Resolve-TeamViewerUserRoleId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserRole + ) + Process { + if ($UserRole.PSObject.TypeNames -contains 'TeamViewerPS.UserRole') { + return [string]$UserRole.RoleID + } + elseif ($UserRole -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { + return [string]$UserRole + } + else { + throw "Invalid role group identifier '$UserRole'. Must be either a [TeamViewerPS.UserRole] or [UUID] " + } + } +} diff --git a/TeamViewerPS/Private/Test-TcpConnection.ps1 b/docs/Cmdlets/Private/Test-TcpConnection.ps1 similarity index 100% rename from TeamViewerPS/Private/Test-TcpConnection.ps1 rename to docs/Cmdlets/Private/Test-TcpConnection.ps1 diff --git a/TeamViewerPS/Private/Test-TeamViewer32on64.ps1 b/docs/Cmdlets/Private/Test-TeamViewer32on64.ps1 similarity index 100% rename from TeamViewerPS/Private/Test-TeamViewer32on64.ps1 rename to docs/Cmdlets/Private/Test-TeamViewer32on64.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1 b/docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1 new file mode 100644 index 0000000..fa6460f --- /dev/null +++ b/docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1 @@ -0,0 +1,53 @@ +function Add-TeamViewerAssignment { + param( + [Parameter(Mandatory = $true)] + [object] + $AssignmentId, + + [string] + $DeviceAlias, + + [int] + $Retries + ) + + + if (Test-TeamViewerInstallation) { + $OS = Get-OperatingSystem + $CurrentDirectory = Get-Location + $installationDirectory = Get-TeamViewerInstallationDirectory + Set-Location $installationDirectory + $CurrentVersion = Get-TeamViewerVersion + $VersionTable = $CurrentVersion.split('.') + if ($OS -eq 'Windows') { + $cmd = "assignment --id $AssignmentId" + $FilePath = 'TeamViewer.exe' + } + elseif ($OS -eq 'Linux') { + $cmd = "teamviewer assignment --id $AssignmentId" + $FilePath = 'sudo' + } + + if ($DeviceAlias) { + if (($VersionTable[0] -eq 15 -and $VersionTable[1] -ge 44) -or $VersionTable[0] -gt 15) { + $cmd += " --device-alias=$DeviceAlias" + } + else { + Write-Error "Current TeamViewer Version: $CurrentVersion does not support the usage of alias. Please update to the latest version." + Set-Location $CurrentDirectory + exit + } + } + if ($Retries) { + $cmd += " --retries=$Retries" + } + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } + else { + Write-Output 'TeamViewer is not installed.' + } +} + + diff --git a/docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1 b/docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1 new file mode 100644 index 0000000..d7f174c --- /dev/null +++ b/docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1 @@ -0,0 +1,48 @@ +Function Add-TeamViewerCustomization { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true, ParameterSetName = 'ById')] + [object] + $Id, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByPath')] + [object] + $Path, + + [switch] + $RestartGUI, + + [switch] + $RemoveExisting + ) + + if (Get-OperatingSystem -eq 'Windows') { + if (Test-TeamViewerInstallation) { + $installationDirectory = Get-TeamViewerInstallationDirectory + $currentDirectory = Get-Location + Set-Location $installationDirectory + $cmd = 'customize' + if ($Id) { + $cmd += " --id $Id" + } + elseif ($Path) { + $cmd += " --path $Path" + } + if ($RemoveExisting) { + $cmd += ' --remove' + } + if ($RestartGUI) { + $cmd += ' --restart-gui' + } + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + Set-Location $currentDirectory + } + else { + Write-Error 'TeamViewer is not installed' + } + } + else { + Write-Error 'Customization is currently supported only on Windows.' + } +} diff --git a/TeamViewerPS/Public/Add-TeamViewerManagedDevice.ps1 b/docs/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Add-TeamViewerManagedDevice.ps1 rename to docs/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1 diff --git a/TeamViewerPS/Public/Add-TeamViewerManager.ps1 b/docs/Cmdlets/Public/Add-TeamViewerManager.ps1 similarity index 100% rename from TeamViewerPS/Public/Add-TeamViewerManager.ps1 rename to docs/Cmdlets/Public/Add-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 new file mode 100644 index 0000000..cec810b --- /dev/null +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 @@ -0,0 +1,64 @@ +function Add-TeamViewerRoleToAccount { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias('Id', 'UserIds')] + [string[]] + $Accounts + ) + + Begin { + $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" + $AccountsToAdd = @() + $body = @{ + UserIds = @() + UserRoleId = $id + } + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($Accounts, 'Assign Account to Role')) { + if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { + $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } + } + foreach ($Account in $Accounts) { + $AccountsToAdd += $Account + $body.UserIds = @($AccountsToAdd) + } + } + if ($AccountsToAdd.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $AccountsToAdd = @() + } + } + End { + if ($AccountsToAdd.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 new file mode 100644 index 0000000..58cd1f3 --- /dev/null +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -0,0 +1,47 @@ +function Add-TeamViewerRoleToUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRoleId')] + [object] + $UserRole, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup + ) + + Begin { + $RoleId = $UserRole | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" + $body = @{ + UserRoleId = $RoleId + UserGroupId = $UserGroup + + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($UserGroup, 'Assign Role to User Group')) { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } +} diff --git a/TeamViewerPS/Public/Add-TeamViewerSsoExclusion.ps1 b/docs/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1 similarity index 100% rename from TeamViewerPS/Public/Add-TeamViewerSsoExclusion.ps1 rename to docs/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1 diff --git a/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 b/docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 similarity index 97% rename from TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 rename to docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 index 9d5d576..6a8acdc 100644 --- a/TeamViewerPS/Public/Add-TeamViewerUserGroupMember.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 @@ -1,84 +1,84 @@ -function Add-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [object[]] - [Alias('UserGroupMemberId')] - [Alias('UserGroupMember')] - [Alias('MemberId')] - [Alias('UserId')] - [Alias('User')] - $Member - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToAdd = @() - $body = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) - } - } - - Process { - # when members are provided as pipeline input, each member is provided as a separate statement, - # thus the members should be combined into one array in order to send a single request. - if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { - if ($Member -notmatch 'u[0-9]+') { - ForEach-Object { - $Member = [int[]]$Member - } - } - else { - ForEach-Object { - $Member = [int[]]$Member.trim('u') - } - } - if ($Member -isnot [array]) { - $membersToAdd = @([UInt32]$Member) - } - else { - $membersToAdd += [UInt32[]]$Member - } - $payload = $membersToAdd -join ', ' - $body = "[$payload]" - } - - # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` - # in order to accept more members - if ($membersToAdd.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $membersToAdd = @() - } - } - - End { - # A request needs to be sent if there were less than 100 members - if ($membersToAdd.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} +function Add-TeamViewerUserGroupMember { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [object[]] + [Alias('UserGroupMemberId')] + [Alias('UserGroupMember')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] + $Member + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToAdd = @() + $body = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) + } + } + + Process { + # when members are provided as pipeline input, each member is provided as a separate statement, + # thus the members should be combined into one array in order to send a single request. + if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { + if ($Member -notmatch 'u[0-9]+') { + ForEach-Object { + $Member = [int[]]$Member + } + } + else { + ForEach-Object { + $Member = [int[]]$Member.trim('u') + } + } + if ($Member -isnot [array]) { + $membersToAdd = @([UInt32]$Member) + } + else { + $membersToAdd += [UInt32[]]$Member + } + $payload = $membersToAdd -join ', ' + $body = "[$payload]" + } + + # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` + # in order to accept more members + if ($membersToAdd.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $membersToAdd = @() + } + } + + End { + # A request needs to be sent if there were less than 100 members + if ($membersToAdd.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} diff --git a/TeamViewerPS/Public/Connect-TeamViewerApi.ps1 b/docs/Cmdlets/Public/Connect-TeamViewerApi.ps1 similarity index 100% rename from TeamViewerPS/Public/Connect-TeamViewerApi.ps1 rename to docs/Cmdlets/Public/Connect-TeamViewerApi.ps1 diff --git a/TeamViewerPS/Public/Disconnect-TeamViewerApi.ps1 b/docs/Cmdlets/Public/Disconnect-TeamViewerApi.ps1 similarity index 100% rename from TeamViewerPS/Public/Disconnect-TeamViewerApi.ps1 rename to docs/Cmdlets/Public/Disconnect-TeamViewerApi.ps1 diff --git a/docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 b/docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 new file mode 100644 index 0000000..3c40695 --- /dev/null +++ b/docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 @@ -0,0 +1,39 @@ +function Export-TeamViewerSystemInformation { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $TargetDirectory + ) + Process { + if (Test-TeamViewerInstallation ) { + if (Get-OperatingSystem -eq 'Windows') { + $Temp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.Guid]::NewGuid().ToString()) + $CurrentDirectory = Get-Location + $Temp | Get-TSCDirectoryFile + $Temp | Get-InstalledSoftware + $Temp | Get-IpConfig + $Temp | Get-MSInfo32 + $Temp | Get-HostFile + $Temp | Get-NSLookUpData + $Temp | Get-RouteTable + $Temp | Get-RegistryPath + $ClientID = Get-ClientId + $ZipFileName = 'TV_SC_' + $ClientID + '_WINPS.zip' + $ZipPath = Join-Path -Path "$Temp\Data" -ChildPath $ZipFileName + Compress-Archive -Path $Temp\* -DestinationPath $ZipPath -Force + if ($TargetDirectory -and (Test-Path $TargetDirectory)) { + Copy-Item -Path $ZipPath -Destination $TargetDirectory -Force + } + else { + Copy-Item -Path $ZipPath -Destination $CurrentDirectory -Force + } + } + else { + Write-Error 'Currently this functionality is supported only on Windows.' + } + } + else { + Write-Error 'TeamViewer is not installed.' + } + } +} diff --git a/TeamViewerPS/Public/Get-TeamViewerAccount.ps1 b/docs/Cmdlets/Public/Get-TeamViewerAccount.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerAccount.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerAccount.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1 b/docs/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerConnectionReport.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerContact.ps1 b/docs/Cmdlets/Public/Get-TeamViewerContact.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerContact.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerContact.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 b/docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 new file mode 100644 index 0000000..5c50ca4 --- /dev/null +++ b/docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 @@ -0,0 +1,22 @@ +function Get-TeamViewerCustomModuleId { + + if (Test-TeamViewerinstallation) { + $fileName = 'TeamViewer.json' + $installationDirectory = Get-TeamViewerInstallationDirectory + $filePath = Join-Path -Path $installationDirectory -ChildPath $fileName + if (Test-Path -Path $filePath) { + $jsonContent = Get-Content -Path $FilePath -Raw + $jsonObject = ConvertFrom-Json $jsonContent + if ($jsonObject.id) { + return $jsonObject.id + } + } + else { + Write-Error 'Custom module Id cannot be found. Check if customization is applied.' + } + } + else { + Write-Error 'TeamViewer is not installed' + } + +} diff --git a/TeamViewerPS/Public/Get-TeamViewerDevice.ps1 b/docs/Cmdlets/Public/Get-TeamViewerDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerDevice.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerDevice.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerEventLog.ps1 b/docs/Cmdlets/Public/Get-TeamViewerEventLog.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerEventLog.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerEventLog.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerGroup.ps1 b/docs/Cmdlets/Public/Get-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerGroup.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerGroup.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerId.ps1 b/docs/Cmdlets/Public/Get-TeamViewerId.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerId.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerId.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 b/docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 new file mode 100644 index 0000000..09748b7 --- /dev/null +++ b/docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 @@ -0,0 +1,27 @@ +function Get-TeamViewerInstallationDirectory { + switch (Get-OperatingSystem) { + 'Windows' { + $regKey = Get-TeamViewerRegKeyPath + $installationDirectory = if (Test-Path $regKey) { + (Get-Item $regKey).GetValue('InstallationDirectory') + } + if ( + $installationDirectory -And ` + (Test-Path "$installationDirectory/TeamViewer.exe") + ) { + return $installationDirectory + } + } + 'Linux' { + if ( + (Test-Path '/opt/teamviewer/tv_bin/TeamViewer') + ) { + return '/opt/teamviewer/tv_bin/' + } + } + default { + Write-Error 'TeamViewer not installed' + } + } +} + diff --git a/docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 b/docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 new file mode 100644 index 0000000..cda13c8 --- /dev/null +++ b/docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 @@ -0,0 +1,38 @@ +function Get-TeamViewerLogFilePath { + param( + [switch] + $OpenFile + ) + + if (Test-TeamViewerInstallation) { + if (Get-OperatingSystem -eq 'Windows') { + $SearchDirectories = Get-TSCSearchDirectory + $LogFiles = New-Object System.Collections.ArrayList + foreach ($Name in $SearchDirectories.Keys) { + $SearchDirectory = $SearchDirectories[$Name] + foreach ($Folder in $SearchDirectory) { + if (Test-Path -Path $Folder) { + $files = Get-ChildItem -Path $Folder -File -Recurse + foreach ($file in $files) { + if ($file.Name.EndsWith('.log')) { + $LogFiles.add($file.FullName) | Out-Null + } + } + } + } + } + + if ($OpenFile) { + $LogFile = $host.ui.PromptForChoice('Select file', 'Choose file:', ` + @($LogFiles), 0) + Invoke-Item -Path $LogFiles[$LogFile] + } + else { + return $LogFiles + } + } + } + else { + Write-Error 'TeamViewer is not installed.' + } +} diff --git a/TeamViewerPS/Public/Get-TeamViewerManagedDevice.ps1 b/docs/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerManagedDevice.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerManagedGroup.ps1 b/docs/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerManagedGroup.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerManagementId.ps1 b/docs/Cmdlets/Public/Get-TeamViewerManagementId.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerManagementId.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerManagementId.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerManager.ps1 b/docs/Cmdlets/Public/Get-TeamViewerManager.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerManager.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerManager.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerPolicy.ps1 b/docs/Cmdlets/Public/Get-TeamViewerPolicy.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerPolicy.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerPolicy.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 b/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 new file mode 100644 index 0000000..ed89a07 --- /dev/null +++ b/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 @@ -0,0 +1,30 @@ +function Get-TeamViewerRoleAssignmentToAccount { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [string] + $UserRoleId + ) + + + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$UserRoleId" + $parameters = $null + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($response.ContinuationToken) { + $resourceUri += '&continuationToken=' + $response.ContinuationToken + } + Write-Output ($response.AssignedToUsers | ConvertTo-TeamViewerRoleAssignedUser ) + }while ($response.ContinuationToken) +} diff --git a/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 b/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 new file mode 100644 index 0000000..3b369c2 --- /dev/null +++ b/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 @@ -0,0 +1,33 @@ +function Get-TeamViewerRoleAssignmentToUserGroup { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript({ $_ | Resolve-TeamviewerUserRoleId })] + [Alias('UserRole')] + [string] + $UserRoleId + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$UserRoleId" + $parameters = $null + } + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($response.ContinuationToken) { + $resourceUri += "&continuationToken=" + $response.ContinuationToken + } + Write-Output ($response.AssignedToGroups | ConvertTo-TeamViewerRoleAssignedUserGroup ) + }while ($response.ContinuationToken) + } +} diff --git a/TeamViewerPS/Public/Get-TeamViewerService.ps1 b/docs/Cmdlets/Public/Get-TeamViewerService.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerService.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerService.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerSsoDomain.ps1 b/docs/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerSsoDomain.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerSsoExclusion.ps1 b/docs/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerSsoExclusion.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerUser.ps1 b/docs/Cmdlets/Public/Get-TeamViewerUser.ps1 similarity index 100% rename from TeamViewerPS/Public/Get-TeamViewerUser.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerUser.ps1 diff --git a/TeamViewerPS/Public/Get-TeamViewerUserGroup.ps1 b/docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1 similarity index 96% rename from TeamViewerPS/Public/Get-TeamViewerUserGroup.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1 index 4778755..8a6e7c1 100644 --- a/TeamViewerPS/Public/Get-TeamViewerUserGroup.ps1 +++ b/docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1 @@ -1,46 +1,46 @@ -function Get-TeamViewerUserGroup { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" - $parameters = @{ } - $isListOperation = $true - - if ($UserGroup) { - $GroupId = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri += "/$GroupId" - $parameters = $null - $isListOperation = $false - } - } - - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($UserGroup) { - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerUserGroup) - } - } while ($isListOperation -And $parameters.paginationToken) - } -} +function Get-TeamViewerUserGroup { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" + $parameters = @{ } + $isListOperation = $true + + if ($UserGroup) { + $GroupId = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri += "/$GroupId" + $parameters = $null + $isListOperation = $false + } + } + + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($UserGroup) { + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerUserGroup) + } + } while ($isListOperation -And $parameters.paginationToken) + } +} diff --git a/TeamViewerPS/Public/Get-TeamViewerUserGroupMember.ps1 b/docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 similarity index 96% rename from TeamViewerPS/Public/Get-TeamViewerUserGroupMember.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 index 48389c0..a3cfdc8 100644 --- a/TeamViewerPS/Public/Get-TeamViewerUserGroupMember.ps1 +++ b/docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 @@ -1,35 +1,35 @@ -function Get-TeamViewerUserGroupMember { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $parameters = @{ } - } - - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerUserGroupMember) - } while ($parameters.paginationToken) - } -} +function Get-TeamViewerUserGroupMember { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $parameters = @{ } + } + + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerUserGroupMember) + } while ($parameters.paginationToken) + } +} diff --git a/docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1 new file mode 100644 index 0000000..3de2ecb --- /dev/null +++ b/docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1 @@ -0,0 +1,24 @@ +function Get-TeamViewerUserRole { + [CmdletBinding(DefaultParameterSetName = '')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + Begin{ + $parameters = @{ } + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + } + +Process{ + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response.Roles | ConvertTo-TeamViewerUserRole ) +} +} diff --git a/TeamViewerPS/Public/Get-TeamViewerVersion.ps1 b/docs/Cmdlets/Public/Get-TeamViewerVersion.ps1 similarity index 52% rename from TeamViewerPS/Public/Get-TeamViewerVersion.ps1 rename to docs/Cmdlets/Public/Get-TeamViewerVersion.ps1 index 2e27836..925d3e1 100644 --- a/TeamViewerPS/Public/Get-TeamViewerVersion.ps1 +++ b/docs/Cmdlets/Public/Get-TeamViewerVersion.ps1 @@ -2,10 +2,10 @@ function Get-TeamViewerVersion { if (Test-TeamViewerInstallation) { switch (Get-OperatingSystem) { 'Windows' { - Write-Output (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'Version') + return (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'Version') } 'Linux' { - Write-Output (Get-TeamViewerLinuxGlobalConfig -Name 'Version') + return (Get-TeamViewerLinuxGlobalConfig -Name 'Version') } } } diff --git a/TeamViewerPS/Public/Invoke-TeamViewerPackageDownload.ps1 b/docs/Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 similarity index 73% rename from TeamViewerPS/Public/Invoke-TeamViewerPackageDownload.ps1 rename to docs/Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 index b344a17..8532ed2 100644 --- a/TeamViewerPS/Public/Invoke-TeamViewerPackageDownload.ps1 +++ b/docs/Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 @@ -1,7 +1,7 @@ function Invoke-TeamViewerPackageDownload { Param( [Parameter()] - [ValidateSet('Full', 'Host', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')] + [ValidateSet('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')] [ValidateScript( { if (($_ -ne 'Full') -And ((Get-OperatingSystem) -ne 'Windows')) { $PSCmdlet.ThrowTerminatingError( @@ -11,7 +11,7 @@ function Invoke-TeamViewerPackageDownload { $true })] [string] - $PackageType = 'Full', + $PackageType, [Parameter()] [ValidateScript( { @@ -20,6 +20,11 @@ function Invoke-TeamViewerPackageDownload { ("MajorVersion parameter is only supported on Windows platforms" | ` ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } + if($PackageType -eq 'MSI32' -or 'MSI64' ){ + $PSCmdlet.ThrowTerminatingError( + ("MajorVersion parameter is not supported for MSI packages" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } if ($_ -lt 14) { $PSCmdlet.ThrowTerminatingError( ("Unsupported TeamViewer version $_" | ` @@ -39,11 +44,19 @@ function Invoke-TeamViewerPackageDownload { $Force ) + if ((-not $PackageType) -And ((Get-OperatingSystem) -eq 'Windows')) { + $Package = $host.ui.PromptForChoice('Select Package Type', 'Choose a package type:', ` + @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit'), 0) + $PackageType = @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')[$Package] + } + $additionalPath = '' switch (Get-OperatingSystem) { 'Windows' { $filename = switch ($PackageType) { 'Full' { 'TeamViewer_Setup.exe' } + 'MSI32' { 'TeamViewer_MSI32.zip' } + 'MSI64' { 'TeamViewer_MSI64.zip' } 'Host' { 'TeamViewer_Host_Setup.exe' } 'Portable' { 'TeamViewerPortable.zip' } 'QuickJoin' { 'TeamViewerQJ.exe' } @@ -53,6 +66,9 @@ function Invoke-TeamViewerPackageDownload { if ($MajorVersion) { $additionalPath = "/version_$($MajorVersion)x" } + if(($PackageType -eq 'MSI32' -or 'MSI64' )){ + $additionalPath = '/version_15x' + } } 'Linux' { $releaseInfo = (Get-Content /etc/*-release) @@ -75,7 +91,7 @@ function Invoke-TeamViewerPackageDownload { } } - $downloadUrl = "https://download.teamviewer.com/download$additionalPath/$filename" + $downloadUrl = "https://dl.teamviewer.com/download$additionalPath/$filename" $targetFile = Join-Path $TargetDirectory $filename if ((Test-Path $targetFile) -And -Not $Force -And ` diff --git a/TeamViewerPS/Public/Invoke-TeamViewerPing.ps1 b/docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1 similarity index 100% rename from TeamViewerPS/Public/Invoke-TeamViewerPing.ps1 rename to docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerContact.ps1 b/docs/Cmdlets/Public/New-TeamViewerContact.ps1 similarity index 100% rename from TeamViewerPS/Public/New-TeamViewerContact.ps1 rename to docs/Cmdlets/Public/New-TeamViewerContact.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerDevice.ps1 b/docs/Cmdlets/Public/New-TeamViewerDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/New-TeamViewerDevice.ps1 rename to docs/Cmdlets/Public/New-TeamViewerDevice.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerGroup.ps1 b/docs/Cmdlets/Public/New-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/New-TeamViewerGroup.ps1 rename to docs/Cmdlets/Public/New-TeamViewerGroup.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerManagedGroup.ps1 b/docs/Cmdlets/Public/New-TeamViewerManagedGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/New-TeamViewerManagedGroup.ps1 rename to docs/Cmdlets/Public/New-TeamViewerManagedGroup.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerPolicy.ps1 b/docs/Cmdlets/Public/New-TeamViewerPolicy.ps1 similarity index 100% rename from TeamViewerPS/Public/New-TeamViewerPolicy.ps1 rename to docs/Cmdlets/Public/New-TeamViewerPolicy.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerUser.ps1 b/docs/Cmdlets/Public/New-TeamViewerUser.ps1 similarity index 100% rename from TeamViewerPS/Public/New-TeamViewerUser.ps1 rename to docs/Cmdlets/Public/New-TeamViewerUser.ps1 diff --git a/TeamViewerPS/Public/New-TeamViewerUserGroup.ps1 b/docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1 similarity index 96% rename from TeamViewerPS/Public/New-TeamViewerUserGroup.ps1 rename to docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1 index 64dc78a..7d9c5f4 100644 --- a/TeamViewerPS/Public/New-TeamViewerUserGroup.ps1 +++ b/docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1 @@ -1,31 +1,31 @@ -function New-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" - $body = @{ name = $Name } - } - - Process { - if ($PSCmdlet.ShouldProcess($Name, "Create user group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - } -} +function New-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" + $body = @{ name = $Name } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, "Create user group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + } +} diff --git a/docs/Cmdlets/Public/New-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/New-TeamViewerUserRole.ps1 new file mode 100644 index 0000000..27a93b3 --- /dev/null +++ b/docs/Cmdlets/Public/New-TeamViewerUserRole.ps1 @@ -0,0 +1,47 @@ + +function New-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true )] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('UserRoleName')] + [string] + $Name, + + [Parameter(Mandatory = $false)] + [AllowEmptyCollection()] + [object[]] + $Permissions + ) + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + $body = @{ + Name = $Name + Permissions = @() + } + + if ($Permissions) { + $body.Permissions = @($Permissions) + } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, 'Create User Role')) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response.Role | ConvertTo-TeamViewerUserRole) + Write-Output $result + } + } + +} diff --git a/TeamViewerPS/Public/Publish-TeamViewerGroup.ps1 b/docs/Cmdlets/Public/Publish-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Publish-TeamViewerGroup.ps1 rename to docs/Cmdlets/Public/Publish-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 new file mode 100644 index 0000000..ac2a59c --- /dev/null +++ b/docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 @@ -0,0 +1,28 @@ +function Remove-TeamViewerAssignment { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + + if (Test-TeamViewerInstallation) { + $OS = Get-OperatingSystem + $CurrentDirectory = Get-Location + $installationDirectory = Get-TeamViewerInstallationDirectory + Set-Location $installationDirectory + if ($OS -eq 'Windows') { + $cmd = 'unassign' + $FilePath = 'TeamViewer.exe' + } + elseif ($OS -eq 'Linux') { + $cmd = 'teamviewer unassign' + $FilePath = 'sudo' + } + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } + else { + Write-Output 'TeamViewer is not installed.' + } +} + + diff --git a/TeamViewerPS/Public/Remove-TeamViewerContact.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerContact.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerContact.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerContact.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 new file mode 100644 index 0000000..0bc1fdc --- /dev/null +++ b/docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 @@ -0,0 +1,22 @@ +function Remove-TeamViewerCustomization { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if (Get-OperatingSystem -eq 'Windows') { + if (Test-TeamViewerInstallation) { + $installationDirectory = Get-TeamViewerInstallationDirectory + $currentDirectory = Get-Location + Set-Location $installationDirectory + $cmd = 'customize --remove' + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + Set-Location $currentDirectory + } + else { + Write-Error 'TeamViewer is not installed' + } + } + else { + Write-Error 'Customization is currently supported only on Windows.' + } +} diff --git a/TeamViewerPS/Public/Remove-TeamViewerDevice.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerDevice.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerDevice.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerGroup.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerGroup.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerGroup.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerManagedDevice.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerManagedDeviceManagement.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerManagedGroup.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerManagedGroup.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerManager.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerManager.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerManager.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 new file mode 100644 index 0000000..faffda7 --- /dev/null +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -0,0 +1,13 @@ +function Remove-TeamViewerPSProxy { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + $global:TeamViewerProxyUriRemoved = $true + $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ + $global:TeamViewerProxyUriSet = $null + $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + [Environment]::SetEnvironmentVariable('TeamViewerProxyUri','', 'User') + } +} diff --git a/TeamViewerPS/Public/Remove-TeamViewerPolicy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPolicy.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerPolicy.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerPolicy.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 new file mode 100644 index 0000000..d92e430 --- /dev/null +++ b/docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 @@ -0,0 +1,63 @@ +function Remove-TeamViewerRoleFromAccount { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias('Id', 'UserIds')] + [string[]] + $Accounts + ) + + Begin { + $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" + $AccountsToRemove = @() + $body = @{ + UserIds = @() + UserRoleId = $id + } + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + + } + + Process { + if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from Role')) { + if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { + $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } + } + foreach ($Account in $Accounts) { + $AccountsToRemove += $Account + $body.UserIds = @($AccountsToRemove) + } + } + if ($AccountsToRemove.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $AccountsToRemove = @() + } + } + End { + if ($AccountsToRemove.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} diff --git a/docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 new file mode 100644 index 0000000..1f53745 --- /dev/null +++ b/docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 @@ -0,0 +1,38 @@ +function Remove-TeamViewerRoleFromUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup + ) + + Begin { + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/usergroup" + $body = @{ + UserGroupId = $UserGroup + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign Role from User Group')) { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } +} diff --git a/TeamViewerPS/Public/Remove-TeamViewerSsoExclusion.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerSsoExclusion.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerUser.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerUser.ps1 similarity index 100% rename from TeamViewerPS/Public/Remove-TeamViewerUser.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerUser.ps1 diff --git a/TeamViewerPS/Public/Remove-TeamViewerUserGroup.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 similarity index 96% rename from TeamViewerPS/Public/Remove-TeamViewerUserGroup.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 index 972b068..6085d9d 100644 --- a/TeamViewerPS/Public/Remove-TeamViewerUserGroup.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 @@ -1,32 +1,32 @@ -function Remove-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" - } - - Process { - if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Remove user group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} +function Remove-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" + } + + Process { + if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Remove user group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} diff --git a/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 similarity index 97% rename from TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 rename to docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 index 24cc8bb..07f5424 100644 --- a/TeamViewerPS/Public/Remove-TeamViewerUserGroupMember.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 @@ -1,95 +1,95 @@ -function Remove-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup, - - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] - [Alias('UserGroupMemberId')] - [Alias('MemberId')] - [Alias('UserId')] - [Alias('User')] - [object[]] - $UserGroupMember - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToRemove = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $UserGroupMember - function Invoke-TeamViewerRestMethodInternal { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - - function Get-MemberId { - switch ($UserGroupMember) { - { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { - $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId - return $UserGroupMember - } - Default { - if ($UserGroupMember -notmatch 'u[0-9]+') { - ForEach-Object { - $UserGroupMember = [int[]]$UserGroupMember - } - } - else { - ForEach-Object { - $UserGroupMember = [int[]]$UserGroupMember.trim('u') - } - } - return $UserGroupMember - } - } - } - } - - Process { - # when members are provided as pipeline input, each member is provided as separate statement, - # thus the members should be combined to one array in order to send a single request - if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { - if (Get-MemberId -isnot [array]) { - $membersToRemove += @(Get-MemberId) - } - else { - $membersToRemove += Get-MemberId - } - $payload = $membersToRemove -join ', ' - $body = "[$payload]" - } - - # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` - # in order to accept more members - if ($membersToRemove.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $membersToRemove = @() - } - } - - End { - # A request needs to be send if there were less than 100 members - if ($membersToRemove.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} +function Remove-TeamViewerUserGroupMember { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup, + + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] + [Alias('UserGroupMemberId')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] + [object[]] + $UserGroupMember + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToRemove = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $UserGroupMember + function Invoke-TeamViewerRestMethodInternal { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + + function Get-MemberId { + switch ($UserGroupMember) { + { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { + $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId + return $UserGroupMember + } + Default { + if ($UserGroupMember -notmatch 'u[0-9]+') { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember + } + } + else { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember.trim('u') + } + } + return $UserGroupMember + } + } + } + } + + Process { + # when members are provided as pipeline input, each member is provided as separate statement, + # thus the members should be combined to one array in order to send a single request + if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { + if (Get-MemberId -isnot [array]) { + $membersToRemove += @(Get-MemberId) + } + else { + $membersToRemove += Get-MemberId + } + $payload = $membersToRemove -join ', ' + $body = "[$payload]" + } + + # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` + # in order to accept more members + if ($membersToRemove.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $membersToRemove = @() + } + } + + End { + # A request needs to be send if there were less than 100 members + if ($membersToRemove.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} diff --git a/docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 new file mode 100644 index 0000000..e83577e --- /dev/null +++ b/docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 @@ -0,0 +1,31 @@ +function Remove-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [Alias('Id')] + [object] + $UserRoleId + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$UserRoleId" + } + + Process { + if ($PSCmdlet.ShouldProcess($UserRoleId.ToString(), 'Remove User Role')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} diff --git a/TeamViewerPS/Public/Restart-TeamViewerService.ps1 b/docs/Cmdlets/Public/Restart-TeamViewerService.ps1 similarity index 87% rename from TeamViewerPS/Public/Restart-TeamViewerService.ps1 rename to docs/Cmdlets/Public/Restart-TeamViewerService.ps1 index 965e6ac..0790234 100644 --- a/TeamViewerPS/Public/Restart-TeamViewerService.ps1 +++ b/docs/Cmdlets/Public/Restart-TeamViewerService.ps1 @@ -2,7 +2,7 @@ function Restart-TeamViewerService { [CmdletBinding(SupportsShouldProcess = $true)] param() - if ($PSCmdlet.ShouldProcess("TeamViewer service")) { + if ($PSCmdlet.ShouldProcess('TeamViewer service')) { switch (Get-OperatingSystem) { 'Windows' { Restart-Service -Name (Get-TeamViewerServiceName) diff --git a/docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 b/docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 new file mode 100644 index 0000000..6737d11 --- /dev/null +++ b/docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 @@ -0,0 +1,24 @@ +function Set-TeamViewerAPIUri { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [Parameter(Mandatory = $false)] + [string]$NewUri, + [Parameter(Mandatory = $false)] + [bool]$Default + ) + + $config = [TeamViewerConfiguration]::GetInstance() + $PSDefaultParameterValues = @{'CmdletName:Default' = $true } + + if ($PSCmdlet.ShouldProcess('TeamViewer account')) { + if ($NewUri) { + $config.APIUri = $NewUri + Write-Output "TeamViewer API URL set to: $($config.APIUri)" + } + elseif ($Default) { + $config.APIUri = 'https://webapi.teamviewer.com/api/v1' + Write-Output "TeamViewer API URL set to: $($config.APIUri)" + } + } + +} diff --git a/TeamViewerPS/Public/Set-TeamViewerAccount.ps1 b/docs/Cmdlets/Public/Set-TeamViewerAccount.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerAccount.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerAccount.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerDevice.ps1 b/docs/Cmdlets/Public/Set-TeamViewerDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerDevice.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerDevice.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerGroup.ps1 b/docs/Cmdlets/Public/Set-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerGroup.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerGroup.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1 b/docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerManagedDevice.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerManagedGroup.ps1 b/docs/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerManagedGroup.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerManager.ps1 b/docs/Cmdlets/Public/Set-TeamViewerManager.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerManager.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 new file mode 100644 index 0000000..be9f49f --- /dev/null +++ b/docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 @@ -0,0 +1,21 @@ +$global:TeamViewerProxyUriSet = $null + +function Set-TeamViewerPSProxy { + [CmdletBinding(SupportsShouldProcess =$true)] + param ( + [Parameter(Mandatory=$true)] + [Uri] + $ProxyUri + ) + + if($PSCmdlet.ShouldProcess($ProxyUri,"Sets proxy for WebAPI")){ + $global:TeamViewerProxyUriSet = $ProxyUri + $global:TeamViewerProxyUriRemoved = $false + $global:TeamViewerProxyUriRemoved | Out-Null + + [Environment]::SetEnvironmentVariable("TeamViewerProxyUri", $ProxyUri, "User") + + Write-Output "Proxy set to $TeamViewerProxyUriSet" + } +} + diff --git a/TeamViewerPS/Public/Set-TeamViewerPolicy.ps1 b/docs/Cmdlets/Public/Set-TeamViewerPolicy.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerPolicy.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerPolicy.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerUser.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUser.ps1 similarity index 100% rename from TeamViewerPS/Public/Set-TeamViewerUser.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerUser.ps1 diff --git a/TeamViewerPS/Public/Set-TeamViewerUserGroup.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1 similarity index 97% rename from TeamViewerPS/Public/Set-TeamViewerUserGroup.ps1 rename to docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1 index 1fb389a..8cd7d5a 100644 --- a/TeamViewerPS/Public/Set-TeamViewerUserGroup.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1 @@ -1,38 +1,38 @@ -function Set-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup, - - [Parameter(Mandatory = $true)] - [Alias("UserGroupName")] - [string] - $Name - ) - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" - $body = @{ name = $Name } - } - Process { - if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Change user group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - } -} +function Set-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup, + + [Parameter(Mandatory = $true)] + [Alias("UserGroupName")] + [string] + $Name + ) + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" + $body = @{ name = $Name } + } + Process { + if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Change user group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + } +} diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 new file mode 100644 index 0000000..aecc984 --- /dev/null +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -0,0 +1,54 @@ + +function Set-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true )] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('UserRoleName')] + [string] + $Name, + + [Parameter(Mandatory = $false)] + [AllowEmptyCollection()] + [object[]] + $Permissions, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId + ) + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + $body = @{ + Name = $Name + Permissions = @() + UserRoleId = $UserRoleId + + } + if ($Permissions) { + $body.Permissions = @($Permissions) + } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = $response + Write-Output $result + } + } + +} diff --git a/TeamViewerPS/Public/Start-TeamViewerService.ps1 b/docs/Cmdlets/Public/Start-TeamViewerService.ps1 similarity index 100% rename from TeamViewerPS/Public/Start-TeamViewerService.ps1 rename to docs/Cmdlets/Public/Start-TeamViewerService.ps1 diff --git a/TeamViewerPS/Public/Stop-TeamViewerService.ps1 b/docs/Cmdlets/Public/Stop-TeamViewerService.ps1 similarity index 100% rename from TeamViewerPS/Public/Stop-TeamViewerService.ps1 rename to docs/Cmdlets/Public/Stop-TeamViewerService.ps1 diff --git a/TeamViewerPS/Public/Test-TeamViewerConnectivity.ps1 b/docs/Cmdlets/Public/Test-TeamViewerConnectivity.ps1 similarity index 100% rename from TeamViewerPS/Public/Test-TeamViewerConnectivity.ps1 rename to docs/Cmdlets/Public/Test-TeamViewerConnectivity.ps1 diff --git a/docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1 b/docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1 new file mode 100644 index 0000000..8cdcf30 --- /dev/null +++ b/docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1 @@ -0,0 +1,8 @@ +function Test-TeamViewerInstallation { + if (Get-TeamViewerInstallationDirectory) { + return $true + } + else { + return $false + } +} diff --git a/TeamViewerPS/Public/Unpublish-TeamViewerGroup.ps1 b/docs/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1 similarity index 100% rename from TeamViewerPS/Public/Unpublish-TeamViewerGroup.ps1 rename to docs/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets_help/Add-TeamViewerAssignment.md b/docs/Cmdlets_help/Add-TeamViewerAssignment.md new file mode 100644 index 0000000..af52fb1 --- /dev/null +++ b/docs/Cmdlets_help/Add-TeamViewerAssignment.md @@ -0,0 +1,98 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Add-TeamViewerAssignment + +## SYNOPSIS + +Assigns the device to a company. + +## SYNTAX + +```powershell +Add-TeamViewerAssignment [-AssignmentId] [-DeviceAlias] [-Retries] +``` + +## DESCRIPTION + +Assigns the particular device to a company listed in managed devices. +Assignment ID can be obtained from Management console under Design & Deploy. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Add-TeamViewerAssignment -AssignmentId '0001CoABChCiJnyAKf0R7r6' +PS /> Add-TeamViewerAssignment -AssignmentId '0001CoABChCiJnyAKf0R7r6' -DeviceAlias 'Test Device 1' +PS /> Add-TeamViewerAssignment -AssignmentId '0001CoABChD3RCXwL6IR7pS' -DeviceAlias 'Test Device 2' -Retries 3 + +``` + +Assigns the devices with default Hostname or with names `Test Device 1` and `Test Device 2` to a Company with the given assignment id. + +## PARAMETERS + +### -AssignmentId + +Object that is required to assign the device to a Company. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: None + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DeviceAlias + +The alias for a device that is set. If omitted the host-name is used. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: None + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Retries + +The assignment is retried in case of temporary errors. There is a waiting time of 1 second between each try. + +```yaml +Type: int +Parameter Sets: (All) +Aliases: None + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +### None + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Add-TeamViewerCustomization.md b/docs/Cmdlets_help/Add-TeamViewerCustomization.md new file mode 100644 index 0000000..a50eb3b --- /dev/null +++ b/docs/Cmdlets_help/Add-TeamViewerCustomization.md @@ -0,0 +1,129 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Add-TeamViewerCustomization + +## SYNOPSIS + +Customizes a TeamViewer Installation. + +## SYNTAX + +```powershell +Add-TeamViewerCustomization [[-Id] || [-Path]] [-RestartGUI][-RemoveExisting] +``` + +## DESCRIPTION + +Customizes a TeamViewer Installation and includes assignment of the particular device to a company if included. +Customization can be perfomed in Management console under Design & Deploy. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Add-TeamViewerCustomization -Id '1234567' +PS /> Add-TeamViewerCustomization -Id '1234567' -RestartGUI +PS /> Add-TeamViewerCustomization -Id '1234567' -RestartGUI -RemoveExisting + +``` + +Customizes the TeamViewer installation with Id. +The next customization to be applied can already be specified after the existing customization removal is performed. +The RestartGUI restarts the running TeamViewer client and the visual changes are applied. + +### Example 2 + +```powershell +PS /> Add-TeamViewerCustomization -Path "X:\67byysp.zip" +PS /> Add-TeamViewerCustomization -Path "X:\67byysp.zip" -RestartGUI +PS /> Add-TeamViewerCustomization -Path "X:\67byysp.zip" -RestartGUI -RemoveExisting + +``` + +Customizes the TeamViewer installation with zip file. +The next customization to be applied can already be specified after the existing customization removal is performed. +The RestartGUI restarts the running TeamViewer client and the visual changes are applied. + +## PARAMETERS + +### -Id + +Object that is required to customize the TeamViewerInstallation. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: None + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Path + +Object to the path of the customization zip file can be specified instead of Id. + +```yaml +Type: object +Parameter Sets: (All) +Aliases: None + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RestartGUI + +Switch to restart the running TeamViewer client to visualize changes. + +```yaml +Type: switch +Parameter Sets: (All) +Aliases: None + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RemoveExisting + +Switch to specify the next customization to be applied after the existing customization is removed. + +```yaml +Type: switch +Parameter Sets: (All) +Aliases: None + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +### None + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Add-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md similarity index 98% rename from docs/commands/Add-TeamViewerManagedDevice.md rename to docs/Cmdlets_help/Add-TeamViewerManagedDevice.md index 3ed7ba4..bdb6f74 100644 --- a/docs/commands/Add-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Add-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Add-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/commands/Add-TeamViewerManager.md b/docs/Cmdlets_help/Add-TeamViewerManager.md similarity index 99% rename from docs/commands/Add-TeamViewerManager.md rename to docs/Cmdlets_help/Add-TeamViewerManager.md index e3dddd2..0f855eb 100644 --- a/docs/commands/Add-TeamViewerManager.md +++ b/docs/Cmdlets_help/Add-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Add-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Add-TeamViewerManager.md schema: 2.0.0 --- @@ -14,48 +14,56 @@ Add a manager to a managed device or managed group. ## SYNTAX ### Device_ByAccountId (Default) + ``` Add-TeamViewerManager -ApiToken -AccountId -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByAccountId + ``` Add-TeamViewerManager -ApiToken -AccountId -Group [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByManagerId + ``` Add-TeamViewerManager -ApiToken -Manager -Group [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Device_ByManagerId + ``` Add-TeamViewerManager -ApiToken -Manager -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByUserObject + ``` Add-TeamViewerManager -ApiToken -User -Group [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Device_ByUserObject + ``` Add-TeamViewerManager -ApiToken -User -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Device_ByUserGroupId + ``` Add-TeamViewerManager -ApiToken -UserGroup -Device [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### Group_ByUserGroupId + ``` Add-TeamViewerManager -ApiToken -UserGroup -Group [-Permissions ] [-WhatIf] [-Confirm] [] @@ -255,6 +263,7 @@ Accept wildcard characters: False ``` ### -UserGroup + UserGroup object as returned from `Get-TeamViewerUserGroup` or Id of the UserGroup which should be added as manager of the targeted managed group or managed device. ```yaml @@ -287,6 +296,7 @@ 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 diff --git a/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md b/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md new file mode 100644 index 0000000..5d1da9f --- /dev/null +++ b/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md @@ -0,0 +1,141 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Add-TeamViewerRoleToAccount + +## SYNOPSIS + +Assign user role to a list of accountIds. + +## SYNTAX + +```powershell +Add-TeamViewerRoleToAccount [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION + +Assigns user role to one or many users. User role should belong to the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Add-TeamViewerRoleToAccount -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +``` + +Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. + +### Example 2 + +```powershell +PS /> @('123', '456', '789') | Add-TeamViewerRoleToAccount -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' +``` + +Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. +Ids are passed as pipeline input. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -UserRoleId + +The role to which users will be assigned to. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Account + +Users to be assigned to a user role. + +```yaml +Type: string[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByValue) +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 +``` + +### 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.string[] + +An array of account Ids. + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md b/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md new file mode 100644 index 0000000..50dfcab --- /dev/null +++ b/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md @@ -0,0 +1,128 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Add-TeamViewerRoleToUserGroup + +## SYNOPSIS + +Assign user role to a user group. + +## SYNTAX + +```powershell +Add-TeamViewerRoleToUserGroup [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION + +Assigns user role to a user group of the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Add-TeamViewerRoleToUserGroup -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 +``` + +The given user group `1001` gets assigned to the user role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -UserRole + +The role to be assigned to the accountIds + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserGroup + +The user group to which the role should be assigned. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: 1 +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 +``` + +### 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/docs/commands/Add-TeamViewerSsoExclusion.md b/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md similarity index 100% rename from docs/commands/Add-TeamViewerSsoExclusion.md rename to docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md diff --git a/docs/commands/Add-TeamViewerUserGroupMember.md b/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md similarity index 93% rename from docs/commands/Add-TeamViewerUserGroupMember.md rename to docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md index 86da423..3ffcaef 100644 --- a/docs/commands/Add-TeamViewerUserGroupMember.md +++ b/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md @@ -1,146 +1,146 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Add-TeamViewerUserGroupMember.md -schema: 2.0.0 ---- - -# Add-TeamViewerUserGroupMember - -## SYNOPSIS - -Add a list of accountIds to a user group. - -## SYNTAX - -```powershell -Add-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [-Member] [-WhatIf] - [-Confirm] [] -``` - -## DESCRIPTION - -Adds a list of accountIds to a user groups of the TeamViewer company associated with the API access token. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> Add-TeamViewerUserGroupMember -Id 1001 -Member @(123, 456, 789) -PS /> Add-TeamViewerUserGroupMember -Id 1001 -Member 123, 456, 789 -``` - -Adds the given accountIds (123, 456, 789) to the user group with Id 1001. - -### Example 2 - -```powershell -PS /> @(123, 456, 789) | Add-TeamViewerUserGroupMember -Id 1001 -``` - -Adds the given accountIds (123, 456, 789) to the user group with Id 1001. -Ids are passed as pipeline input. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -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 -``` - -### -Member - -The list of accounts Ids to be added as member of the group. - -```yaml -Type: Int32[] -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -UserGroup - -The groups where accounts will be added as members - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: Id, UserGroupId - -Required: True -Position: 1 -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 -``` - -### 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[] - -An array of account Ids. - -## OUTPUTS - -### System.Object - -An array of `TeamViewerPS.UserGroupMember` objects. - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md +schema: 2.0.0 +--- + +# Add-TeamViewerUserGroupMember + +## SYNOPSIS + +Add a list of accountIds to a user group. + +## SYNTAX + +```powershell +Add-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [-Member] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION + +Adds a list of accountIds to a user groups of the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Add-TeamViewerUserGroupMember -Id 1001 -Member @(123, 456, 789) +PS /> Add-TeamViewerUserGroupMember -Id 1001 -Member 123, 456, 789 +``` + +Adds the given accountIds (123, 456, 789) to the user group with Id 1001. + +### Example 2 + +```powershell +PS /> @(123, 456, 789) | Add-TeamViewerUserGroupMember -Id 1001 +``` + +Adds the given accountIds (123, 456, 789) to the user group with Id 1001. +Ids are passed as pipeline input. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -Member + +The list of accounts Ids to be added as member of the group. + +```yaml +Type: Int32[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -UserGroup + +The groups where accounts will be added as members + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: 1 +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 +``` + +### 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[] + +An array of account Ids. + +## OUTPUTS + +### System.Object + +An array of `TeamViewerPS.UserGroupMember` objects. + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Connect-TeamViewerApi.md b/docs/Cmdlets_help/Connect-TeamViewerApi.md similarity index 96% rename from docs/commands/Connect-TeamViewerApi.md rename to docs/Cmdlets_help/Connect-TeamViewerApi.md index fd09af6..fc3b872 100644 --- a/docs/commands/Connect-TeamViewerApi.md +++ b/docs/Cmdlets_help/Connect-TeamViewerApi.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Connect-TeamViewerApi.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Connect-TeamViewerApi.md schema: 2.0.0 --- diff --git a/docs/commands/Disconnect-TeamViewerApi.md b/docs/Cmdlets_help/Disconnect-TeamViewerApi.md similarity index 95% rename from docs/commands/Disconnect-TeamViewerApi.md rename to docs/Cmdlets_help/Disconnect-TeamViewerApi.md index 350c6d8..0243e3d 100644 --- a/docs/commands/Disconnect-TeamViewerApi.md +++ b/docs/Cmdlets_help/Disconnect-TeamViewerApi.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Disconnect-TeamViewerApi.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Disconnect-TeamViewerApi.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md b/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md new file mode 100644 index 0000000..417e50a --- /dev/null +++ b/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md @@ -0,0 +1,72 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Export-TeamViewerSystemInformation + +## SYNOPSIS + +Collect the files required by TeamViewer support and zip them. + +## SYNTAX + +```powershell +Export-TeamViewerSystemInformation [[-TargetDirectory] ] [] +``` + +## DESCRIPTION + +Collects the files required by TeamViewer support and creates a zip file with clientID in its name. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Export-TeamViewerSystemInformation +``` + +The zip file is created and stored in the working directory. + +### Example 2 + +```powershell +PS C:\> Export-TeamViewerSystemInformation -TargetDirectory "C:\" +``` + +The zip file is created and stored in the target directory + +## PARAMETERS + +### -TargetDirectory + +Specify the target directory to store TeamViewer support file. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +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 + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Get-TeamViewerAccount.md b/docs/Cmdlets_help/Get-TeamViewerAccount.md similarity index 96% rename from docs/commands/Get-TeamViewerAccount.md rename to docs/Cmdlets_help/Get-TeamViewerAccount.md index d470b76..9ab3a95 100644 --- a/docs/commands/Get-TeamViewerAccount.md +++ b/docs/Cmdlets_help/Get-TeamViewerAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerAccount.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerConnectionReport.md b/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md similarity index 99% rename from docs/commands/Get-TeamViewerConnectionReport.md rename to docs/Cmdlets_help/Get-TeamViewerConnectionReport.md index fd820a0..8b92591 100644 --- a/docs/commands/Get-TeamViewerConnectionReport.md +++ b/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerConnectionReport.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerConnectionReport.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerContact.md b/docs/Cmdlets_help/Get-TeamViewerContact.md similarity index 98% rename from docs/commands/Get-TeamViewerContact.md rename to docs/Cmdlets_help/Get-TeamViewerContact.md index 5a80fb1..47bc1b2 100644 --- a/docs/commands/Get-TeamViewerContact.md +++ b/docs/Cmdlets_help/Get-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md b/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md new file mode 100644 index 0000000..cca477c --- /dev/null +++ b/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md @@ -0,0 +1,48 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerCustomModuleId + +## SYNOPSIS + +Retrieves the currently applied TeamViewer custom module's ID. + +## SYNTAX + +```powershell +Get-TeamViewerCustomModuleId +``` + +## DESCRIPTION + +The command checks the TeamViewer Installation and returns the custom module ID. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerCustomModuleId +``` + +Returns the custom module id. + +## PARAMETERS + +### CommonParameters + +### None + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Get-TeamViewerDevice.md b/docs/Cmdlets_help/Get-TeamViewerDevice.md similarity index 98% rename from docs/commands/Get-TeamViewerDevice.md rename to docs/Cmdlets_help/Get-TeamViewerDevice.md index ca34be8..888ce76 100644 --- a/docs/commands/Get-TeamViewerDevice.md +++ b/docs/Cmdlets_help/Get-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerEventLog.md b/docs/Cmdlets_help/Get-TeamViewerEventLog.md similarity index 99% rename from docs/commands/Get-TeamViewerEventLog.md rename to docs/Cmdlets_help/Get-TeamViewerEventLog.md index 0e975d4..f1026e2 100644 --- a/docs/commands/Get-TeamViewerEventLog.md +++ b/docs/Cmdlets_help/Get-TeamViewerEventLog.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerEventLog.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerEventLog.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerGroup.md b/docs/Cmdlets_help/Get-TeamViewerGroup.md similarity index 98% rename from docs/commands/Get-TeamViewerGroup.md rename to docs/Cmdlets_help/Get-TeamViewerGroup.md index 5b583bf..0591504 100644 --- a/docs/commands/Get-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerId.md b/docs/Cmdlets_help/Get-TeamViewerId.md similarity index 95% rename from docs/commands/Get-TeamViewerId.md rename to docs/Cmdlets_help/Get-TeamViewerId.md index df4a471..08762b5 100644 --- a/docs/commands/Get-TeamViewerId.md +++ b/docs/Cmdlets_help/Get-TeamViewerId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md b/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md new file mode 100644 index 0000000..79a212f --- /dev/null +++ b/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md @@ -0,0 +1,48 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerInstallationDirectory + +## SYNOPSIS + +Retrieves the TeamViewer installation directory. + +## SYNTAX + +```powershell +Get-TeamViewerInstallationDirectory +``` + +## DESCRIPTION + +The command checks the TeamViewer Installation and returns the installation directory. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerInstallationDirectory +``` + +Returns the installation directory. + +## PARAMETERS + +### CommonParameters + +### None + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md b/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md new file mode 100644 index 0000000..0efa86b --- /dev/null +++ b/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md @@ -0,0 +1,70 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerLogFilePath + +## SYNOPSIS + +Retrieves TeamViewer log files. + +## SYNTAX + +```powershell +Get-TeamViewerLogFilePath -OpenFile +``` + +## DESCRIPTION + +The command checks the required directories and returns the paths for log files. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerLogFilePath +``` + +Returns the paths for log files. + +### Example 2 + +```powershell +PS /> Get-TeamViewerLogFilePath -OpenFile +``` + +Provides a prompt with choice to open the located files. + +## PARAMETERS + +### -OpenFile + +Switch to open a log file. + +```yaml +Type: switch +Parameter Sets: (All) +Aliases: None + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +### None + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Get-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md similarity index 98% rename from docs/commands/Get-TeamViewerManagedDevice.md rename to docs/Cmdlets_help/Get-TeamViewerManagedDevice.md index 574ffff..b8f4044 100644 --- a/docs/commands/Get-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerManagedGroup.md b/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md similarity index 97% rename from docs/commands/Get-TeamViewerManagedGroup.md rename to docs/Cmdlets_help/Get-TeamViewerManagedGroup.md index d598571..565e970 100644 --- a/docs/commands/Get-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerManagementId.md b/docs/Cmdlets_help/Get-TeamViewerManagementId.md similarity index 94% rename from docs/commands/Get-TeamViewerManagementId.md rename to docs/Cmdlets_help/Get-TeamViewerManagementId.md index d461eb4..9aa40da 100644 --- a/docs/commands/Get-TeamViewerManagementId.md +++ b/docs/Cmdlets_help/Get-TeamViewerManagementId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerManagementId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManagementId.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerManager.md b/docs/Cmdlets_help/Get-TeamViewerManager.md similarity index 97% rename from docs/commands/Get-TeamViewerManager.md rename to docs/Cmdlets_help/Get-TeamViewerManager.md index 67a3298..e56b062 100644 --- a/docs/commands/Get-TeamViewerManager.md +++ b/docs/Cmdlets_help/Get-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerPolicy.md b/docs/Cmdlets_help/Get-TeamViewerPolicy.md similarity index 97% rename from docs/commands/Get-TeamViewerPolicy.md rename to docs/Cmdlets_help/Get-TeamViewerPolicy.md index 8873109..9ff614c 100644 --- a/docs/commands/Get-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/Get-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md new file mode 100644 index 0000000..6657d4e --- /dev/null +++ b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md @@ -0,0 +1,84 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerRoleAssignmentToAccount + +## SYNOPSIS + +Lists all user role assignments of a user role. + +## SYNTAX + +```powershell +Get-TeamViewerRoleAssignmentToAccount [-ApiToken] [-UserRoleId] [] +``` + +## DESCRIPTION + +Lists all user role assignments of user role in the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerRoleAssignmentToAccount -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' +``` + +Lists all user assignments of user role `72abbedc-9853-4fc8-9d28-fa35e207b048`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserRoleId + +UserRole to list its assigned users. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: 1 +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 + +An array of `TeamViewerPS.RoleAssignedUser` objects. + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md new file mode 100644 index 0000000..0ddc527 --- /dev/null +++ b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md @@ -0,0 +1,84 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerRoleAssignmentToUserGroup + +## SYNOPSIS + +Lists all user group assignments of a user role. + +## SYNTAX + +```powershell +Get-TeamViewerRoleAssignmentToUserGroup [-ApiToken] [-UserRoleId] [] +``` + +## DESCRIPTION + +Lists all user group assignments of a user role in the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerRoleAssignmentToUserGroup -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' +``` + +Lists all user group assignments of user role `72abbedc-9853-4fc8-9d28-fa35e207b048`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserRoleId + +UserRole to list its assigned users. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: 1 +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 + +An array of `TeamViewerPS.RoleAssignedUserGroup` objects. + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Get-TeamViewerService.md b/docs/Cmdlets_help/Get-TeamViewerService.md similarity index 95% rename from docs/commands/Get-TeamViewerService.md rename to docs/Cmdlets_help/Get-TeamViewerService.md index de5ef17..cf09164 100644 --- a/docs/commands/Get-TeamViewerService.md +++ b/docs/Cmdlets_help/Get-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/commands/Get-TeamViewerSsoDomain.md b/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md similarity index 100% rename from docs/commands/Get-TeamViewerSsoDomain.md rename to docs/Cmdlets_help/Get-TeamViewerSsoDomain.md diff --git a/docs/commands/Get-TeamViewerSsoExclusion.md b/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md similarity index 100% rename from docs/commands/Get-TeamViewerSsoExclusion.md rename to docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md diff --git a/docs/commands/Get-TeamViewerUser.md b/docs/Cmdlets_help/Get-TeamViewerUser.md similarity index 97% rename from docs/commands/Get-TeamViewerUser.md rename to docs/Cmdlets_help/Get-TeamViewerUser.md index 6e2a1e2..72edf51 100644 --- a/docs/commands/Get-TeamViewerUser.md +++ b/docs/Cmdlets_help/Get-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerUser.md schema: 2.0.0 --- @@ -146,7 +146,7 @@ Accept wildcard characters: False ### -PropertiesToLoad Can be used to retrieve all available properties of a user or just a -stripped-down mininal set of user properties. +stripped-down minimal set of user properties. ```yaml Type: Object diff --git a/docs/commands/Get-TeamViewerUserGroup.md b/docs/Cmdlets_help/Get-TeamViewerUserGroup.md similarity index 92% rename from docs/commands/Get-TeamViewerUserGroup.md rename to docs/Cmdlets_help/Get-TeamViewerUserGroup.md index fb7eaf3..356186f 100644 --- a/docs/commands/Get-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerUserGroup.md @@ -1,93 +1,93 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-Get-TeamViewerUserGroup.md -schema: 2.0.0 ---- - -# Get-TeamViewerUserGroup - -## SYNOPSIS - -Retrieve user groups of a TeamViewer company. - -## SYNTAX - -```powershell -Get-TeamViewerUserGroup [-ApiToken] [[-UserGroup] ] [] -``` - -## DESCRIPTION - -Lists all user groups of the TeamViewer company associated with the API access token. -The list can optionally be filtered using additional parameters. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> Get-TeamViewerUserGroup -``` - -List all user groups. - -### Example 2 - -```powershell -PS /> Get-TeamViewerUserGroup -Id 1001 -``` - -Retrieve a single user group with id 1001. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UserGroup - -Optional UserGroup that can be used to only get information of a specific user group. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: Id, UserGroupId - -Required: False -Position: 1 -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 - -An array of `TeamViewerPS.UserGroup` objects. - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-Get-TeamViewerUserGroup.md +schema: 2.0.0 +--- + +# Get-TeamViewerUserGroup + +## SYNOPSIS + +Retrieve user groups of a TeamViewer company. + +## SYNTAX + +```powershell +Get-TeamViewerUserGroup [-ApiToken] [[-UserGroup] ] [] +``` + +## DESCRIPTION + +Lists all user groups of the TeamViewer company associated with the API access token. +The list can optionally be filtered using additional parameters. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerUserGroup +``` + +List all user groups. + +### Example 2 + +```powershell +PS /> Get-TeamViewerUserGroup -Id 1001 +``` + +Retrieve a single user group with id 1001. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserGroup + +Optional UserGroup that can be used to only get information of a specific user group. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: False +Position: 1 +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 + +An array of `TeamViewerPS.UserGroup` objects. + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Get-TeamViewerUserGroupMember.md b/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md similarity index 92% rename from docs/commands/Get-TeamViewerUserGroupMember.md rename to docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md index 2f468c7..73513ed 100644 --- a/docs/commands/Get-TeamViewerUserGroupMember.md +++ b/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md @@ -1,84 +1,84 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerUserGroupMember.md -schema: 2.0.0 ---- - -# Get-TeamViewerUserGroupMember - -## SYNOPSIS - -List all members of a user group. - -## SYNTAX - -```powershell -Get-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [] -``` - -## DESCRIPTION - -Lists all members of a user group of the TeamViewer company associated with the API access token. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> Get-TeamViewerUserGroupMember -Id 1001 -``` - -List members all members of the user group with Id 1001. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UserGroup - -UserGroup to list its members. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: Id, UserGroupId - -Required: True -Position: 1 -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 - -An array of `TeamViewerPS.UserGroupMember` objects. - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md +schema: 2.0.0 +--- + +# Get-TeamViewerUserGroupMember + +## SYNOPSIS + +List all members of a user group. + +## SYNTAX + +```powershell +Get-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [] +``` + +## DESCRIPTION + +Lists all members of a user group of the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerUserGroupMember -Id 1001 +``` + +List members all members of the user group with Id 1001. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserGroup + +UserGroup to list its members. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: 1 +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 + +An array of `TeamViewerPS.UserGroupMember` objects. + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Get-TeamViewerUserRole.md b/docs/Cmdlets_help/Get-TeamViewerUserRole.md new file mode 100644 index 0000000..b00c835 --- /dev/null +++ b/docs/Cmdlets_help/Get-TeamViewerUserRole.md @@ -0,0 +1,68 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Get-TeamViewerUserRole + +## SYNOPSIS + +Retrieve user roles in a TeamViewer company. + +## SYNTAX + +```powershell +Get-TeamViewerUserRole [-ApiToken] [] +``` + +## DESCRIPTION + +Lists all user roles in the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerUserRole +``` + +List all user roles and their permissions. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 + +An array of `TeamViewerPS.UserRole` objects. + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Get-TeamViewerVersion.md b/docs/Cmdlets_help/Get-TeamViewerVersion.md similarity index 95% rename from docs/commands/Get-TeamViewerVersion.md rename to docs/Cmdlets_help/Get-TeamViewerVersion.md index 9a8af15..2799057 100644 --- a/docs/commands/Get-TeamViewerVersion.md +++ b/docs/Cmdlets_help/Get-TeamViewerVersion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Get-TeamViewerVersion.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerVersion.md schema: 2.0.0 --- diff --git a/docs/commands/Invoke-TeamViewerPackageDownload.md b/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md similarity index 93% rename from docs/commands/Invoke-TeamViewerPackageDownload.md rename to docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md index 6cfff1e..9ad211e 100644 --- a/docs/commands/Invoke-TeamViewerPackageDownload.md +++ b/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Invoke-TeamViewerPackageDownload.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md schema: 2.0.0 --- @@ -81,7 +81,7 @@ available on Windows platforms. Type: String Parameter Sets: (All) Aliases: -Accepted values: Full, Host, Portable, QuickJoin, QuickSupport, Full64Bit +Accepted values: Full, Host, MSI32, MSI64, Portable, QuickJoin, QuickSupport, Full64Bit Required: False Position: 0 diff --git a/docs/commands/Invoke-TeamViewerPing.md b/docs/Cmdlets_help/Invoke-TeamViewerPing.md similarity index 96% rename from docs/commands/Invoke-TeamViewerPing.md rename to docs/Cmdlets_help/Invoke-TeamViewerPing.md index 864dc38..cfeab33 100644 --- a/docs/commands/Invoke-TeamViewerPing.md +++ b/docs/Cmdlets_help/Invoke-TeamViewerPing.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Invoke-TeamViewerPing.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Invoke-TeamViewerPing.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerContact.md b/docs/Cmdlets_help/New-TeamViewerContact.md similarity index 98% rename from docs/commands/New-TeamViewerContact.md rename to docs/Cmdlets_help/New-TeamViewerContact.md index 63f7bf6..c0d710d 100644 --- a/docs/commands/New-TeamViewerContact.md +++ b/docs/Cmdlets_help/New-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerDevice.md b/docs/Cmdlets_help/New-TeamViewerDevice.md similarity index 98% rename from docs/commands/New-TeamViewerDevice.md rename to docs/Cmdlets_help/New-TeamViewerDevice.md index 305a606..d06f3fb 100644 --- a/docs/commands/New-TeamViewerDevice.md +++ b/docs/Cmdlets_help/New-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerGroup.md b/docs/Cmdlets_help/New-TeamViewerGroup.md similarity index 98% rename from docs/commands/New-TeamViewerGroup.md rename to docs/Cmdlets_help/New-TeamViewerGroup.md index 9a62a70..2d67ee3 100644 --- a/docs/commands/New-TeamViewerGroup.md +++ b/docs/Cmdlets_help/New-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerManagedGroup.md b/docs/Cmdlets_help/New-TeamViewerManagedGroup.md similarity index 97% rename from docs/commands/New-TeamViewerManagedGroup.md rename to docs/Cmdlets_help/New-TeamViewerManagedGroup.md index 8c9cf2a..e5803ee 100644 --- a/docs/commands/New-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/New-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerPolicy.md b/docs/Cmdlets_help/New-TeamViewerPolicy.md similarity index 98% rename from docs/commands/New-TeamViewerPolicy.md rename to docs/Cmdlets_help/New-TeamViewerPolicy.md index 5802180..6970c1a 100644 --- a/docs/commands/New-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/New-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerUser.md b/docs/Cmdlets_help/New-TeamViewerUser.md similarity index 99% rename from docs/commands/New-TeamViewerUser.md rename to docs/Cmdlets_help/New-TeamViewerUser.md index 2c1b0f0..05793e1 100644 --- a/docs/commands/New-TeamViewerUser.md +++ b/docs/Cmdlets_help/New-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/commands/New-TeamViewerUserGroup.md b/docs/Cmdlets_help/New-TeamViewerUserGroup.md similarity index 93% rename from docs/commands/New-TeamViewerUserGroup.md rename to docs/Cmdlets_help/New-TeamViewerUserGroup.md index 77c3946..53ec43a 100644 --- a/docs/commands/New-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/New-TeamViewerUserGroup.md @@ -1,119 +1,119 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/New-TeamViewerUserGroup.md -schema: 2.0.0 ---- - -# New-TeamViewerUserGroup - -## SYNOPSIS - -Create a new user group. - -## SYNTAX - -``` powershell -New-TeamViewerUserGroup [-ApiToken] [-Name] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION - -Create a new user group that belongs to the TeamViewer company associated with the API access token. -The name of the new user group should be unique among the groups of the TeamViewer Company. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> New-TeamViewerUserGroup -Name 'New user group' -``` - -Creates a new user groups with name `New user group`. -The name should be unique among the groups of the TeamViewer Company. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -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 -``` - -### -Name - -The name of the new user group. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -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 -``` - -### 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 - -A `TeamViewerPS.UserGroup` object. - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerUserGroup.md +schema: 2.0.0 +--- + +# New-TeamViewerUserGroup + +## SYNOPSIS + +Create a new user group. + +## SYNTAX + +``` powershell +New-TeamViewerUserGroup [-ApiToken] [-Name] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Create a new user group that belongs to the TeamViewer company associated with the API access token. +The name of the new user group should be unique among the groups of the TeamViewer Company. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> New-TeamViewerUserGroup -Name 'New user group' +``` + +Creates a new user groups with name `New user group`. +The name should be unique among the groups of the TeamViewer Company. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -Name + +The name of the new user group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +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 +``` + +### 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 + +A `TeamViewerPS.UserGroup` object. + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/New-TeamViewerUserRole.md b/docs/Cmdlets_help/New-TeamViewerUserRole.md new file mode 100644 index 0000000..1881be5 --- /dev/null +++ b/docs/Cmdlets_help/New-TeamViewerUserRole.md @@ -0,0 +1,144 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# New-TeamViewerUserRole + +## SYNOPSIS + +Create a new user role. + +## SYNTAX + +``` powershell +New-TeamViewerUserRole [-ApiToken] [-Name] [-Permissions] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Create a new user role that belongs to the TeamViewer company associated with the API access token. +The name of the new user role should be unique among the roles of the TeamViewer Company. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> New-TeamViewerUserRole -Name 'New user role' -Permissions 'AllowGroupharing','ManageConnections' +``` + +Creates a new user role with name `New user role` with permissions `AllowGroupSharing` and `ManageConnections` enabled. +Please see the TeamViewer API documentation for a list of valid values. + +### Example 2 + +```powershell +PS /> New-TeamViewerUserRole -Name 'New user role' +``` + +Creates a new user role with name `New user role` without any permissions. +The name should be unique among the roles of the TeamViewer Company. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -Name + +The name of the new user role. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Permissions + +The permissions for the user role. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +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 +``` + +### 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 + +A `TeamViewerPS.UserRole` object. + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Publish-TeamViewerGroup.md b/docs/Cmdlets_help/Publish-TeamViewerGroup.md similarity index 98% rename from docs/commands/Publish-TeamViewerGroup.md rename to docs/Cmdlets_help/Publish-TeamViewerGroup.md index df4c156..5e692c9 100644 --- a/docs/commands/Publish-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Publish-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Publish-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Publish-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerAssignment.md b/docs/Cmdlets_help/Remove-TeamViewerAssignment.md new file mode 100644 index 0000000..ac6e507 --- /dev/null +++ b/docs/Cmdlets_help/Remove-TeamViewerAssignment.md @@ -0,0 +1,48 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerAssignment + +## SYNOPSIS + +Unassigns the device from its current company. + +## SYNTAX + +```powershell +Remove-TeamViewerAssignment +``` + +## DESCRIPTION + +Unassigns the calling device from its company. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerAssignment +``` + +Unassigns the device from its company. + +## PARAMETERS + +### CommonParameters + +### None + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Remove-TeamViewerContact.md b/docs/Cmdlets_help/Remove-TeamViewerContact.md similarity index 97% rename from docs/commands/Remove-TeamViewerContact.md rename to docs/Cmdlets_help/Remove-TeamViewerContact.md index 1b02f08..ed944d3 100644 --- a/docs/commands/Remove-TeamViewerContact.md +++ b/docs/Cmdlets_help/Remove-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerCustomization.md b/docs/Cmdlets_help/Remove-TeamViewerCustomization.md new file mode 100644 index 0000000..69a56cb --- /dev/null +++ b/docs/Cmdlets_help/Remove-TeamViewerCustomization.md @@ -0,0 +1,47 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerCustomization + +## SYNOPSIS + +Removes the customization from the TeamViewer Installation. + +## SYNTAX + +```powershell +Remove-TeamViewerCustomization +``` + +## DESCRIPTION + +Removes the existing customization from the TeamViewer Installation. +Existing customization should be removed before applying new customization. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerAssignment +``` + +Removes the customization. + +## PARAMETERS + +### CommonParameters + +### None + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Remove-TeamViewerDevice.md b/docs/Cmdlets_help/Remove-TeamViewerDevice.md similarity index 97% rename from docs/commands/Remove-TeamViewerDevice.md rename to docs/Cmdlets_help/Remove-TeamViewerDevice.md index 64182be..caf9dc8 100644 --- a/docs/commands/Remove-TeamViewerDevice.md +++ b/docs/Cmdlets_help/Remove-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/commands/Remove-TeamViewerGroup.md b/docs/Cmdlets_help/Remove-TeamViewerGroup.md similarity index 97% rename from docs/commands/Remove-TeamViewerGroup.md rename to docs/Cmdlets_help/Remove-TeamViewerGroup.md index 9d9f313..639ae92 100644 --- a/docs/commands/Remove-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/commands/Remove-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md similarity index 98% rename from docs/commands/Remove-TeamViewerManagedDevice.md rename to docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md index 33ec45c..8579a4d 100644 --- a/docs/commands/Remove-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/commands/Remove-TeamViewerManagedDeviceManagement.md b/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md similarity index 97% rename from docs/commands/Remove-TeamViewerManagedDeviceManagement.md rename to docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md index 6c2197e..7bc797a 100644 --- a/docs/commands/Remove-TeamViewerManagedDeviceManagement.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerManagedDeviceManagement.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md schema: 2.0.0 --- diff --git a/docs/commands/Remove-TeamViewerManagedGroup.md b/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md similarity index 97% rename from docs/commands/Remove-TeamViewerManagedGroup.md rename to docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md index 21949b3..e1f1801 100644 --- a/docs/commands/Remove-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/commands/Remove-TeamViewerManager.md b/docs/Cmdlets_help/Remove-TeamViewerManager.md similarity index 98% rename from docs/commands/Remove-TeamViewerManager.md rename to docs/Cmdlets_help/Remove-TeamViewerManager.md index ebcc52c..a1fce2e 100644 --- a/docs/commands/Remove-TeamViewerManager.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md b/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md new file mode 100644 index 0000000..7f514e1 --- /dev/null +++ b/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md @@ -0,0 +1,46 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerPSProxy + +## SYNOPSIS + +Remove TeamViewerPS proxy. + +## SYNTAX + +```powershell +Remove-TeamViewerPSProxy +``` + +## DESCRIPTION + +Removes the proxy and sets it to default for TeamViewerPS module functions. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerPSProxy +``` + +Removes the existing proxy server used and sets it to default. + +## PARAMETERS + +### CommonParameters + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Remove-TeamViewerPolicy.md b/docs/Cmdlets_help/Remove-TeamViewerPolicy.md similarity index 97% rename from docs/commands/Remove-TeamViewerPolicy.md rename to docs/Cmdlets_help/Remove-TeamViewerPolicy.md index 8897dd4..45337fd 100644 --- a/docs/commands/Remove-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/Remove-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/commands/Remove-TeamViewerPolicyFromManagedDevice.md b/docs/Cmdlets_help/Remove-TeamViewerPolicyFromManagedDevice.md similarity index 100% rename from docs/commands/Remove-TeamViewerPolicyFromManagedDevice.md rename to docs/Cmdlets_help/Remove-TeamViewerPolicyFromManagedDevice.md diff --git a/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md b/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md new file mode 100644 index 0000000..43a4ef5 --- /dev/null +++ b/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md @@ -0,0 +1,152 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerRoleFromAccount + +## SYNOPSIS + +Unassign role from a given list of accounts. + +## SYNTAX + +### ByUserRoleIdMemberId (All) + +```powershell +Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserRoleId] [-Account] + [-WhatIf] [-Confirm] [] +``` + +### ByUserId + +```powershell +Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserRoleId] [-Account] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Unassigns user role from one or many users. User role should belong to the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerRoleFromAccount -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +``` + +Unassigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` from users with id `123`, `456`, `789`. + +### Example 2 + +```powershell +PS /> @('123', '456', '789') | Remove-TeamViewerRoleFromAccount -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +``` + +Unassigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` from users with id `123`, `456`, `789`. +Ids are passed as pipeline input. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +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 +``` + +### -UserRoleId + +The role from where users will be unassigned from. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Account + +Users to be unassigned from a user role. + +```yaml +Type: Object[] +Parameter Sets: (All) +Aliases: Id, UserId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +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 +``` + +### 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.Object + +### System.string[] + +An array of account Ids. + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md b/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md new file mode 100644 index 0000000..4a8446a --- /dev/null +++ b/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md @@ -0,0 +1,112 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerRoleFromAccount + +## SYNOPSIS + +Unassign user role from a user group. + +## SYNTAX + +```powershell +Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserGroup] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION + +Unassigns user role from a user group of the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerRoleFromAccount -UserGroup 1001 +``` + +The given user group `1001` gets unassigned from its user role. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -UserGroup + +The user group from which user role should be unassigned. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: 1 +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 +``` + +### 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/docs/commands/Remove-TeamViewerSsoExclusion.md b/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md similarity index 100% rename from docs/commands/Remove-TeamViewerSsoExclusion.md rename to docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md diff --git a/docs/commands/Remove-TeamViewerUser.md b/docs/Cmdlets_help/Remove-TeamViewerUser.md similarity index 100% rename from docs/commands/Remove-TeamViewerUser.md rename to docs/Cmdlets_help/Remove-TeamViewerUser.md diff --git a/docs/commands/Remove-TeamViewerUserGroup.md b/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md similarity index 93% rename from docs/commands/Remove-TeamViewerUserGroup.md rename to docs/Cmdlets_help/Remove-TeamViewerUserGroup.md index 3df26a6..796441c 100644 --- a/docs/commands/Remove-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md @@ -1,124 +1,124 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerUserGroup.md -schema: 2.0.0 ---- - -# Remove-TeamViewerUserGroup - -## SYNOPSIS - -Delete a user group from the TeamViewer company. - -## SYNTAX - -```powershell -Remove-TeamViewerUserGroup [-ApiToken] [-UserGroup] [-WhatIf] [-Confirm] - [] -``` - -## DESCRIPTION - -Deletes a use groups from the TeamViewer company. -All information regarding the user group will be deleted too. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> Remove-TeamViewerUserGroup -Id 1001 -``` - -Deletes the user group with Id `1001`. - -### Example 2 - -```powershell -PS /> Remove-TeamViewerUserGroup -UserGroup (Get-TeamViewerUserGroup | Where-Object { $_.Name -eq "Test Group" }) -``` - -Remove a user group object retrieved using `Get-TeamViewerUserGroup` as input. -In this example, the user group with the name `Test Group`. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -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 -``` - -### -UserGroup - -The user groups to be deleted. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: Id, UserGroupId - -Required: True -Position: 1 -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 -``` - -### 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 - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerUserGroup.md +schema: 2.0.0 +--- + +# Remove-TeamViewerUserGroup + +## SYNOPSIS + +Delete a user group from the TeamViewer company. + +## SYNTAX + +```powershell +Remove-TeamViewerUserGroup [-ApiToken] [-UserGroup] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION + +Deletes a use groups from the TeamViewer company. +All information regarding the user group will be deleted too. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerUserGroup -Id 1001 +``` + +Deletes the user group with Id `1001`. + +### Example 2 + +```powershell +PS /> Remove-TeamViewerUserGroup -UserGroup (Get-TeamViewerUserGroup | Where-Object { $_.Name -eq "Test Group" }) +``` + +Remove a user group object retrieved using `Get-TeamViewerUserGroup` as input. +In this example, the user group with the name `Test Group`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -UserGroup + +The user groups to be deleted. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: 1 +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 +``` + +### 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 + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Remove-TeamViewerUserGroupMember.md b/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md similarity index 93% rename from docs/commands/Remove-TeamViewerUserGroupMember.md rename to docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md index 6c9162d..ebad7dc 100644 --- a/docs/commands/Remove-TeamViewerUserGroupMember.md +++ b/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md @@ -1,185 +1,185 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Remove-TeamViewerUserGroupMember.md -schema: 2.0.0 ---- - -# Remove-TeamViewerUserGroupMember - -## SYNOPSIS - -Deletes members from a given user group. - -## SYNTAX - -### ByUserGroupMemberId (All) - -```powershell -Remove-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [-UserGroupMember] - [-WhatIf] [-Confirm] [] -``` - -### ByUserId - -```powershell -Remove-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [-User] - [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION - -Deletes one or many members from a user group. User group should belong to the TeamViewer company associated with the API access token. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> Remove-TeamViewerUserGroupMember -UserGroup 1001 -UserGroupMember @(123, 456, 789) -``` - -Removes the accounts `123`, `456`, `789` from the group with id `1001`. - -### Example 2 - -```powershell -PS /> @(123, 456, 789) | Remove-TeamViewerUserGroupMember -UserGroup 1001 -``` - -Removes the accounts `123`, `456`, `789` from the group with id `1001`. -Ids are passed as pipeline input. - -### Example 3 - -```powershell -PS /> Remove-TeamViewerUserGroupMember -UserGroup 1001 -User @('u123', 'u456', 'u789') -``` - -Removes the users `u123`, `u456`, `u789` from the group with id `1001`. - -### Example 4 - -```powershell -PS /> Get-TeamViewerUserGroupMember -UserGroup 1001 | Remove-TeamViewerUserGroupMember -UserGroup 1001 -``` - -Removes all the users from the group with id `1001`. -Ids are passed as pipeline input. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -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 -``` - -### -User - -Users to be removed from a user group. - -```yaml -Type: Object[] -Parameter Sets: ByUserId -Aliases: UserId - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -UserGroup - -The group where members will be removed from. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: Id, UserGroupId - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UserGroupMember - -User group members to be removed from a user group. - -```yaml -Type: Object[] -Parameter Sets: (ByUserGroupMemberId) -Aliases: MemberId, UserGroupMemberId - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -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 -``` - -### 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.Object - -### System.Int32[] - -An array of account Ids. - -## OUTPUTS - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md +schema: 2.0.0 +--- + +# Remove-TeamViewerUserGroupMember + +## SYNOPSIS + +Deletes members from a given user group. + +## SYNTAX + +### ByUserGroupMemberId (All) + +```powershell +Remove-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [-UserGroupMember] + [-WhatIf] [-Confirm] [] +``` + +### ByUserId + +```powershell +Remove-TeamViewerUserGroupMember [-ApiToken] [-UserGroup] [-User] + [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Deletes one or many members from a user group. User group should belong to the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerUserGroupMember -UserGroup 1001 -UserGroupMember @(123, 456, 789) +``` + +Removes the accounts `123`, `456`, `789` from the group with id `1001`. + +### Example 2 + +```powershell +PS /> @(123, 456, 789) | Remove-TeamViewerUserGroupMember -UserGroup 1001 +``` + +Removes the accounts `123`, `456`, `789` from the group with id `1001`. +Ids are passed as pipeline input. + +### Example 3 + +```powershell +PS /> Remove-TeamViewerUserGroupMember -UserGroup 1001 -User @('u123', 'u456', 'u789') +``` + +Removes the users `u123`, `u456`, `u789` from the group with id `1001`. + +### Example 4 + +```powershell +PS /> Get-TeamViewerUserGroupMember -UserGroup 1001 | Remove-TeamViewerUserGroupMember -UserGroup 1001 +``` + +Removes all the users from the group with id `1001`. +Ids are passed as pipeline input. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +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 +``` + +### -User + +Users to be removed from a user group. + +```yaml +Type: Object[] +Parameter Sets: ByUserId +Aliases: UserId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -UserGroup + +The group where members will be removed from. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserGroupMember + +User group members to be removed from a user group. + +```yaml +Type: Object[] +Parameter Sets: (ByUserGroupMemberId) +Aliases: MemberId, UserGroupMemberId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +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 +``` + +### 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.Object + +### System.Int32[] + +An array of account Ids. + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserRole.md b/docs/Cmdlets_help/Remove-TeamViewerUserRole.md new file mode 100644 index 0000000..2edf25a --- /dev/null +++ b/docs/Cmdlets_help/Remove-TeamViewerUserRole.md @@ -0,0 +1,124 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Remove-TeamViewerUserRole + +## SYNOPSIS + +Delete a user role from the TeamViewer company. + +## SYNTAX + +```powershell +Remove-TeamViewerUserRole [-ApiToken] [-UserRoleId] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION + +Deletes a user role from the TeamViewer company. +All permissions and assignments of the user role will be deleted too. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +``` + +Deletes the user role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. + +### Example 2 + +```powershell +PS /> Remove-TeamViewerUserRole -UserRoleId (Get-TeamViewerUserRole | Where-Object { ($_.RoleName -eq 'Test Role') } ).RoleID +``` + +Removes a user role with RoleId retrieved using `Get-TeamViewerUserRole` as input. +In this example, the user role with the name `Test Role`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -UserRoleId + +The user role to be deleted. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserRole + +Required: True +Position: 1 +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 +``` + +### 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 + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Restart-TeamViewerService.md b/docs/Cmdlets_help/Restart-TeamViewerService.md similarity index 96% rename from docs/commands/Restart-TeamViewerService.md rename to docs/Cmdlets_help/Restart-TeamViewerService.md index 2687fbf..95dd02f 100644 --- a/docs/commands/Restart-TeamViewerService.md +++ b/docs/Cmdlets_help/Restart-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Restart-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Restart-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerAccount.md b/docs/Cmdlets_help/Set-TeamViewerAccount.md similarity index 98% rename from docs/commands/Set-TeamViewerAccount.md rename to docs/Cmdlets_help/Set-TeamViewerAccount.md index 2158f76..96b0b00 100644 --- a/docs/commands/Set-TeamViewerAccount.md +++ b/docs/Cmdlets_help/Set-TeamViewerAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerAccount.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerDevice.md b/docs/Cmdlets_help/Set-TeamViewerDevice.md similarity index 99% rename from docs/commands/Set-TeamViewerDevice.md rename to docs/Cmdlets_help/Set-TeamViewerDevice.md index d2f1a32..30ae954 100644 --- a/docs/commands/Set-TeamViewerDevice.md +++ b/docs/Cmdlets_help/Set-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerGroup.md b/docs/Cmdlets_help/Set-TeamViewerGroup.md similarity index 98% rename from docs/commands/Set-TeamViewerGroup.md rename to docs/Cmdlets_help/Set-TeamViewerGroup.md index cc729d6..6554c40 100644 --- a/docs/commands/Set-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Set-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Set-TeamViewerManagedDevice.md similarity index 100% rename from docs/commands/Set-TeamViewerManagedDevice.md rename to docs/Cmdlets_help/Set-TeamViewerManagedDevice.md diff --git a/docs/commands/Set-TeamViewerManagedGroup.md b/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md similarity index 98% rename from docs/commands/Set-TeamViewerManagedGroup.md rename to docs/Cmdlets_help/Set-TeamViewerManagedGroup.md index 62b99de..cfee11c 100644 --- a/docs/commands/Set-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerManager.md b/docs/Cmdlets_help/Set-TeamViewerManager.md similarity index 99% rename from docs/commands/Set-TeamViewerManager.md rename to docs/Cmdlets_help/Set-TeamViewerManager.md index fee966a..8a7b7a4 100644 --- a/docs/commands/Set-TeamViewerManager.md +++ b/docs/Cmdlets_help/Set-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerPSProxy.md b/docs/Cmdlets_help/Set-TeamViewerPSProxy.md new file mode 100644 index 0000000..e87029c --- /dev/null +++ b/docs/Cmdlets_help/Set-TeamViewerPSProxy.md @@ -0,0 +1,68 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Set-TeamViewerPSProxy + +## SYNOPSIS + +Set TeamViewerPS to use proxy. + +## SYNTAX + +```powershell +Set-TeamViewerPSProxy [-ProxyUri] [] +``` + +## DESCRIPTION + +Sets a Proxy to access webAPI for TeamViewerPS module functions. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Set-TeamViewerPSProxy -ProxyUri "http://example.com/port" +``` + +Sets the proxy server to "". + +### Example 2 + +```powershell +PS /> Set-TeamViewerPSProxy -ProxyUri "http://10.0.0.1:3128" +``` + +Sets the proxy server to "". + +## PARAMETERS + +### -ProxyUri + +The Proxy server Uri. + +```yaml +Type: Uri +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Set-TeamViewerPolicy.md b/docs/Cmdlets_help/Set-TeamViewerPolicy.md similarity index 98% rename from docs/commands/Set-TeamViewerPolicy.md rename to docs/Cmdlets_help/Set-TeamViewerPolicy.md index f21eb86..7ad75ec 100644 --- a/docs/commands/Set-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/Set-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerUser.md b/docs/Cmdlets_help/Set-TeamViewerUser.md similarity index 99% rename from docs/commands/Set-TeamViewerUser.md rename to docs/Cmdlets_help/Set-TeamViewerUser.md index 8d69416..619491d 100644 --- a/docs/commands/Set-TeamViewerUser.md +++ b/docs/Cmdlets_help/Set-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/commands/Set-TeamViewerUserGroup.md b/docs/Cmdlets_help/Set-TeamViewerUserGroup.md similarity index 93% rename from docs/commands/Set-TeamViewerUserGroup.md rename to docs/Cmdlets_help/Set-TeamViewerUserGroup.md index 53a5b35..ea7e283 100644 --- a/docs/commands/Set-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/Set-TeamViewerUserGroup.md @@ -1,135 +1,135 @@ ---- -external help file: TeamViewerPS-help.xml -Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Set-TeamViewerUserGroup.md -schema: 2.0.0 ---- - -# Set-TeamViewerUserGroup - -## SYNOPSIS - -Update properties of a user group. - -## SYNTAX - -```powershell -Set-TeamViewerUserGroup [-ApiToken] [-UserGroup] [-Name] [-WhatIf] [-Confirm] - [] -``` - -## DESCRIPTION - -Update properties of a user group. Currently it is only possible to rename a group. -New name should be unique among all user groups of the TeamViewer company. - -## EXAMPLES - -### Example 1 - -```powershell -PS /> Set-TeamViewerUserGroup -UserGroup 1001 -Name 'New name of the user group' -``` - -Renames a user group with id `1001` to `New name of the user group`. - -## PARAMETERS - -### -ApiToken - -The TeamViewer API access token. - -```yaml -Type: SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -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 -``` - -### -Name - -The new name of the group. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: UserGroupName - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UserGroup - -The user group to be updated. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: Id, UserGroupId - -Required: True -Position: 1 -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 -``` - -### 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 - -A `TeamViewerPS.UserGroup` object. - -## NOTES - -## RELATED LINKS +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerUserGroup.md +schema: 2.0.0 +--- + +# Set-TeamViewerUserGroup + +## SYNOPSIS + +Update properties of a user group. + +## SYNTAX + +```powershell +Set-TeamViewerUserGroup [-ApiToken] [-UserGroup] [-Name] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION + +Update properties of a user group. Currently it is only possible to rename a group. +New name should be unique among all user groups of the TeamViewer company. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Set-TeamViewerUserGroup -UserGroup 1001 -Name 'New name of the user group' +``` + +Renames a user group with id `1001` to `New name of the user group`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -Name + +The new name of the group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: UserGroupName + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserGroup + +The user group to be updated. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Id, UserGroupId + +Required: True +Position: 1 +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 +``` + +### 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 + +A `TeamViewerPS.UserGroup` object. + +## NOTES + +## RELATED LINKS diff --git a/docs/Cmdlets_help/Set-TeamViewerUserRole.md b/docs/Cmdlets_help/Set-TeamViewerUserRole.md new file mode 100644 index 0000000..f08939f --- /dev/null +++ b/docs/Cmdlets_help/Set-TeamViewerUserRole.md @@ -0,0 +1,130 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: +schema: 2.0.0 +--- + +# Set-TeamViewerUserRole + +## SYNOPSIS + +Update properties of a user role. + +## SYNTAX + +```powershell +Set-TeamViewerUserRole [-ApiToken] [-Name] [-UserRoleId] [-Permissions] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Update properties of a user role. It allows to rename and alter permissions. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Set-TeamViewerUserRole -Name 'New name of user role' -Permissions 'AllowGroupSharing','ModifyConnections' -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +``` + +Renames a user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to `New name of user role` and enables the permissions `AllowGroupSharing` and `ModifyConnections`. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name + +The new name of the User role. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: UserRoleName + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UserRoleId + +The user role to be updated. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Permissions + +Updated set of permissions of the user role. +Please see the TeamViewer API documentation for a list of valid values. + +```yaml +Type: Array +Parameter Sets: ByParameters +Aliases: + +Required: False +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 +``` + +### 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 + +## NOTES + +## RELATED LINKS diff --git a/docs/commands/Start-TeamViewerService.md b/docs/Cmdlets_help/Start-TeamViewerService.md similarity index 96% rename from docs/commands/Start-TeamViewerService.md rename to docs/Cmdlets_help/Start-TeamViewerService.md index 38bf289..a5f3907 100644 --- a/docs/commands/Start-TeamViewerService.md +++ b/docs/Cmdlets_help/Start-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Start-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Start-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/commands/Stop-TeamViewerService.md b/docs/Cmdlets_help/Stop-TeamViewerService.md similarity index 96% rename from docs/commands/Stop-TeamViewerService.md rename to docs/Cmdlets_help/Stop-TeamViewerService.md index d744923..0aa28b8 100644 --- a/docs/commands/Stop-TeamViewerService.md +++ b/docs/Cmdlets_help/Stop-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Stop-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Stop-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/commands/Test-TeamViewerConnectivity.md b/docs/Cmdlets_help/Test-TeamViewerConnectivity.md similarity index 96% rename from docs/commands/Test-TeamViewerConnectivity.md rename to docs/Cmdlets_help/Test-TeamViewerConnectivity.md index 720c967..8fbc5cf 100644 --- a/docs/commands/Test-TeamViewerConnectivity.md +++ b/docs/Cmdlets_help/Test-TeamViewerConnectivity.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Test-TeamViewerConnectivity.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Test-TeamViewerConnectivity.md schema: 2.0.0 --- diff --git a/docs/commands/Test-TeamViewerInstallation.md b/docs/Cmdlets_help/Test-TeamViewerInstallation.md similarity index 94% rename from docs/commands/Test-TeamViewerInstallation.md rename to docs/Cmdlets_help/Test-TeamViewerInstallation.md index ecbc658..465c41a 100644 --- a/docs/commands/Test-TeamViewerInstallation.md +++ b/docs/Cmdlets_help/Test-TeamViewerInstallation.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Test-TeamViewerInstallation.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Test-TeamViewerInstallation.md schema: 2.0.0 --- diff --git a/docs/commands/Unpublish-TeamViewerGroup.md b/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md similarity index 97% rename from docs/commands/Unpublish-TeamViewerGroup.md rename to docs/Cmdlets_help/Unpublish-TeamViewerGroup.md index 2881d5e..0996292 100644 --- a/docs/commands/Unpublish-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/commands/Unpublish-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Unpublish-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/TeamViewerPS/TeamViewerPS.Types.ps1 b/docs/TeamViewerPS.Types.ps1 similarity index 100% rename from TeamViewerPS/TeamViewerPS.Types.ps1 rename to docs/TeamViewerPS.Types.ps1 diff --git a/TeamViewerPS/TeamViewerPS.format.ps1xml b/docs/TeamViewerPS.format.ps1xml similarity index 100% rename from TeamViewerPS/TeamViewerPS.format.ps1xml rename to docs/TeamViewerPS.format.ps1xml diff --git a/TeamViewerPS/TeamViewerPS.psd1 b/docs/TeamViewerPS.psd1 similarity index 99% rename from TeamViewerPS/TeamViewerPS.psd1 rename to docs/TeamViewerPS.psd1 index 97eeb1d..0ffbf58 100644 --- a/TeamViewerPS/TeamViewerPS.psd1 +++ b/docs/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '1.5.1' + ModuleVersion = '2.0.0' # Supported PSEditions. # CompatiblePSEditions = @() diff --git a/TeamViewerPS/TeamViewerPS.psm1 b/docs/TeamViewerPS.psm1 similarity index 54% rename from TeamViewerPS/TeamViewerPS.psm1 rename to docs/TeamViewerPS.psm1 index 7106f40..e373072 100644 --- a/TeamViewerPS/TeamViewerPS.psm1 +++ b/docs/TeamViewerPS.psm1 @@ -1,6 +1,6 @@ $ModuleTypes = @( Get-ChildItem -Path "$PSScriptRoot/TeamViewerPS.Types.ps1" -ErrorAction SilentlyContinue ) -$PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -ErrorAction SilentlyContinue ) -$PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -ErrorAction SilentlyContinue ) +$PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Cmdlets/Public/*.ps1" -ErrorAction SilentlyContinue ) +$PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Cmdlets/Private/*.ps1" -ErrorAction SilentlyContinue ) @($ModuleTypes + $PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * diff --git a/docs/about_TeamViewerPS.md b/docs/about_TeamViewerPS.md index 6c8fe9f..4b066e5 100644 --- a/docs/about_TeamViewerPS.md +++ b/docs/about_TeamViewerPS.md @@ -20,31 +20,31 @@ Remotely manage the Computers & Contacts list via the TeamViewer Web API. The following functions are available in this category: -[`Get-TeamViewerContact`](commands/Get-TeamViewerContact.md) +[`Get-TeamViewerContact`](Cmdlets/Public/Get-TeamViewerContact.md) -[`Get-TeamViewerDevice`](commands/Get-TeamViewerDevice.md) +[`Get-TeamViewerDevice`](Cmdlets/Public/Get-TeamViewerDevice.md) -[`Get-TeamViewerGroup`](commands/Get-TeamViewerGroup.md) +[`Get-TeamViewerGroup`](Cmdlets/Public/Get-TeamViewerGroup.md) -[`New-TeamViewerContact`](commands/New-TeamViewerContact.md) +[`New-TeamViewerContact`](Cmdlets/Public/New-TeamViewerContact.md) -[`New-TeamViewerDevice`](commands/New-TeamViewerDevice.md) +[`New-TeamViewerDevice`](Cmdlets/Public/New-TeamViewerDevice.md) -[`New-TeamViewerGroup`](commands/New-TeamViewerGroup.md) +[`New-TeamViewerGroup`](Cmdlets/Public/New-TeamViewerGroup.md) -[`Remove-TeamViewerContact`](commands/Remove-TeamViewerContact.md) +[`Remove-TeamViewerContact`](Cmdlets/Public/Remove-TeamViewerContact.md) -[`Remove-TeamViewerDevice`](commands/Remove-TeamViewerDevice.md) +[`Remove-TeamViewerDevice`](Cmdlets/Public/Remove-TeamViewerDevice.md) -[`Remove-TeamViewerGroup`](commands/Remove-TeamViewerGroup.md) +[`Remove-TeamViewerGroup`](Cmdlets/Public/Remove-TeamViewerGroup.md) -[`Set-TeamViewerDevice`](commands/Set-TeamViewerDevice.md) +[`Set-TeamViewerDevice`](Cmdlets/Public/Set-TeamViewerDevice.md) -[`Set-TeamViewerGroup`](commands/Set-TeamViewerGroup.md) +[`Set-TeamViewerGroup`](Cmdlets/Public/Set-TeamViewerGroup.md) -[`Publish-TeamViewerGroup`](commands/Publish-TeamViewerGroup.md) +[`Publish-TeamViewerGroup`](Cmdlets/Public/Publish-TeamViewerGroup.md) -[`Unpublish-TeamViewerGroup`](commands/Unpublish-TeamViewerGroup.md) +[`Unpublish-TeamViewerGroup`](Cmdlets/Public/Unpublish-TeamViewerGroup.md) ## User management @@ -53,13 +53,13 @@ Web API. The following functions are available in this category: -[`Get-TeamViewerUser`](commands/Get-TeamViewerUser.md) +[`Get-TeamViewerUser`](Cmdlets/Public/Get-TeamViewerUser.md) -[`New-TeamViewerUser`](commands/New-TeamViewerUser.md) +[`New-TeamViewerUser`](Cmdlets/Public/New-TeamViewerUser.md) -[`Remove-TeamViewerUser`](commands/Remove-TeamViewerUser.md) +[`Remove-TeamViewerUser`](Cmdlets/Public/Remove-TeamViewerUser.md) -[`Set-TeamViewerUser`](commands/Set-TeamViewerUser.md) +[`Set-TeamViewerUser`](Cmdlets/Public/Set-TeamViewerUser.md) ## User groups @@ -68,19 +68,19 @@ TeamViewer Web API. Have user groups to organize company members. The following functions are available in this category: -[`Get-TeamViewerUserGroup`](commands/Get-TeamViewerUserGroup.md) +[`Get-TeamViewerUserGroup`](Cmdlets/Public/Get-TeamViewerUserGroup.md) -[`New-TeamViewerUserGroup`](commands/New-TeamViewerUserGroup.md) +[`New-TeamViewerUserGroup`](Cmdlets/Public/New-TeamViewerUserGroup.md) -[`Set-TeamViewerUserGroup`](commands/Set-TeamViewerUserGroup.md) +[`Set-TeamViewerUserGroup`](Cmdlets/Public/Set-TeamViewerUserGroup.md) -[`Remove-TeamViewerUserGroup`](commands/Remove-TeamViewerUserGroup.md) +[`Remove-TeamViewerUserGroup`](Cmdlets/Public/Remove-TeamViewerUserGroup.md) -[`Get-TeamViewerUserGroupMember`](commands/Get-TeamViewerUserGroupMember.md) +[`Get-TeamViewerUserGroupMember`](Cmdlets/Public/Get-TeamViewerUserGroupMember.md) -[`Add-TeamViewerUserGroupMember`](commands/Add-TeamViewerUserGroupMember.md) +[`Add-TeamViewerUserGroupMember`](Cmdlets/Public/Add-TeamViewerUserGroupMember.md) -[`Remove-TeamViewerUserGroupMember`](commands/Remove-TeamViewerUserGroupMember.md) +[`Remove-TeamViewerUserGroupMember`](Cmdlets/Public/Remove-TeamViewerUserGroupMember.md) ## Managed groups @@ -89,33 +89,33 @@ TeamViewer Web API. The following functions are available in this category: -[`Get-TeamViewerManagedDevice`](commands/Get-TeamViewerManagedDevice.md) +[`Get-TeamViewerManagedDevice`](Cmdlets/Public/Get-TeamViewerManagedDevice.md) -[`Get-TeamViewerManagedGroup`](commands/Get-TeamViewerManagedGroup.md) +[`Get-TeamViewerManagedGroup`](Cmdlets/Public/Get-TeamViewerManagedGroup.md) -[`Get-TeamViewerManagementId`](commands/Get-TeamViewerManagementId.md) +[`Get-TeamViewerManagementId`](Cmdlets/Public/Get-TeamViewerManagementId.md) -[`Get-TeamViewerManager`](commands/Get-TeamViewerManager.md) +[`Get-TeamViewerManager`](Cmdlets/Public/Get-TeamViewerManager.md) -[`New-TeamViewerManagedGroup`](commands/New-TeamViewerManagedGroup.md) +[`New-TeamViewerManagedGroup`](Cmdlets/Public/New-TeamViewerManagedGroup.md) -[`Set-TeamViewerManagedDevice`](commands/Set-TeamViewerManagedDevice.md) +[`Set-TeamViewerManagedDevice`](Cmdlets/Public/Set-TeamViewerManagedDevice.md) -[`Set-TeamViewerManagedGroup`](commands/Set-TeamViewerManagedGroup.md) +[`Set-TeamViewerManagedGroup`](Cmdlets/Public/Set-TeamViewerManagedGroup.md) -[`Set-TeamViewerManager`](commands/Set-TeamViewerManager.md) +[`Set-TeamViewerManager`](Cmdlets/Public/Set-TeamViewerManager.md) -[`Add-TeamViewerManagedDevice`](commands/Add-TeamViewerManagedDevice.md) +[`Add-TeamViewerManagedDevice`](Cmdlets/Public/Add-TeamViewerManagedDevice.md) -[`Add-TeamViewerManager`](commands/Add-TeamViewerManager.md) +[`Add-TeamViewerManager`](Cmdlets/Public/Add-TeamViewerManager.md) -[`Remove-TeamViewerManagedDevice`](commands/Remove-TeamViewerManagedDevice.md) +[`Remove-TeamViewerManagedDevice`](Cmdlets/Public/Remove-TeamViewerManagedDevice.md) -[`Remove-TeamViewerManagedDeviceManagement`](commands/Remove-TeamViewerManagedDeviceManagement.md) +[`Remove-TeamViewerManagedDeviceManagement`](Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.md) -[`Remove-TeamViewerManagedGroup`](commands/Remove-TeamViewerManagedGroup.md) +[`Remove-TeamViewerManagedGroup`](Cmdlets/Public/Remove-TeamViewerManagedGroup.md) -[`Remove-TeamViewerManager`](commands/Remove-TeamViewerManager.md) +[`Remove-TeamViewerManager`](Cmdlets/Public/Remove-TeamViewerManager.md) ## Policy management @@ -123,13 +123,13 @@ Remotely manage the policies of a TeamViewer company via the TeamViewer Web API. The following functions are available in this category: -[`Get-TeamViewerPolicy`](commands/Get-TeamViewerPolicy.md) +[`Get-TeamViewerPolicy`](Cmdlets/Public/Get-TeamViewerPolicy.md) -[`New-TeamViewerPolicy`](commands/New-TeamViewerPolicy.md) +[`New-TeamViewerPolicy`](Cmdlets/Public/New-TeamViewerPolicy.md) -[`Remove-TeamViewerPolicy`](commands/Remove-TeamViewerPolicy.md) +[`Remove-TeamViewerPolicy`](Cmdlets/Public/Remove-TeamViewerPolicy.md) -[`Set-TeamViewerPolicy`](commands/Set-TeamViewerPolicy.md) +[`Set-TeamViewerPolicy`](Cmdlets/Public/Set-TeamViewerPolicy.md) ## Single Sign-On management @@ -137,22 +137,22 @@ Remotely manage Single Sign-On configurations via the TeamViewer Web API. The following functions are available in this category: -[`Get-TeamViewerSsoDomain`](commands/Get-TeamViewerSsoDomain.md) +[`Get-TeamViewerSsoDomain`](Cmdlets/Public/Get-TeamViewerSsoDomain.md) -[`Get-TeamViewerSsoExclusion`](commands/Get-TeamViewerSsoExclusion.md) +[`Get-TeamViewerSsoExclusion`](Cmdlets/Public/Get-TeamViewerSsoExclusion.md) -[`Add-TeamViewerSsoExclusion`](commands/Add-TeamViewerSsoExclusion.md) +[`Add-TeamViewerSsoExclusion`](Cmdlets/Public/Add-TeamViewerSsoExclusion.md) -[`Remove-TeamViewerSsoExclusion`](commands/Remove-TeamViewerSsoExclusion.md) +[`Remove-TeamViewerSsoExclusion`](Cmdlets/Public/Remove-TeamViewerSsoExclusion.md) ## Event logs & reporting Retrieve event log entries or connection-reports of a TeamViewer company via the TeamViewer Web API. -[`Get-TeamViewerConnectionReport`](commands/Get-TeamViewerConnectionReport.md) +[`Get-TeamViewerConnectionReport`](Cmdlets/Public/Get-TeamViewerConnectionReport.md) -[`Get-TeamViewerEventLog`](commands/Get-TeamViewerEventLog.md) +[`Get-TeamViewerEventLog`](Cmdlets/Public/Get-TeamViewerEventLog.md) ## Local TeamViewer utilities @@ -160,23 +160,23 @@ Utilities that help managing the local TeamViewer installation. The following functions are available in this category: -[`Get-TeamViewerId`](commands/Get-TeamViewerId.md) +[`Get-TeamViewerId`](Cmdlets/Public/Get-TeamViewerId.md) -[`Get-TeamViewerService`](commands/Get-TeamViewerService.md) +[`Get-TeamViewerService`](Cmdlets/Public/Get-TeamViewerService.md) -[`Get-TeamViewerVersion`](commands/Get-TeamViewerVersion.md) +[`Get-TeamViewerVersion`](Cmdlets/Public/Get-TeamViewerVersion.md) -[`Invoke-TeamViewerPackageDownload`](commands/Invoke-TeamViewerPackageDownload.md) +[`Invoke-TeamViewerPackageDownload`](Cmdlets/Public/Invoke-TeamViewerPackageDownload.md) -[`Restart-TeamViewerService`](commands/Restart-TeamViewerService.md) +[`Restart-TeamViewerService`](Cmdlets/Public/Restart-TeamViewerService.md) -[`Start-TeamViewerService`](commands/Start-TeamViewerService.md) +[`Start-TeamViewerService`](Cmdlets/Public/Start-TeamViewerService.md) -[`Stop-TeamViewerService`](commands/Stop-TeamViewerService.md) +[`Stop-TeamViewerService`](Cmdlets/Public/Stop-TeamViewerService.md) -[`Test-TeamViewerConnectivity`](commands/Test-TeamViewerConnectivity.md) +[`Test-TeamViewerConnectivity`](Cmdlets/Public/Test-TeamViewerConnectivity.md) -[`Test-TeamViewerInstallation`](commands/Test-TeamViewerInstallation.md) +[`Test-TeamViewerInstallation`](Cmdlets/Public/Test-TeamViewerInstallation.md) ## Web API utilities @@ -184,11 +184,11 @@ Utilities that help working with the TeamViewer Web API related functions. The following functions are available in this category: -[`Connect-TeamViewerApi`](commands/Connect-TeamViewerApi.md) +[`Connect-TeamViewerApi`](Cmdlets/Public/Connect-TeamViewerApi.md) -[`Disconnect-TeamViewerApi`](commands/Disconnect-TeamViewerApi.md) +[`Disconnect-TeamViewerApi`](Cmdlets/Public/Disconnect-TeamViewerApi.md) -[`Invoke-TeamViewerPing`](commands/Invoke-TeamViewerPing.md) +[`Invoke-TeamViewerPing`](Cmdlets/Public/Invoke-TeamViewerPing.md) # SEE ALSO From 58007c4872bcbbdbcd7b76c9a8a5152f8cb0f1ec Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Tue, 19 Sep 2023 15:01:49 +0200 Subject: [PATCH 034/110] -RemovePolicy switch removed from Set-TeamViewerManagedDevice and links to help files added --- .../Set-TeamViewerManagedDevice.Tests.ps1 | 23 ------------------- .../Public/Set-TeamViewerManagedDevice.ps1 | 18 +++------------ docs/Cmdlets_help/Add-TeamViewerAssignment.md | 2 +- .../Add-TeamViewerCustomization.md | 2 +- .../Add-TeamViewerManagedDevice.md | 2 +- docs/Cmdlets_help/Add-TeamViewerManager.md | 2 +- .../Add-TeamViewerRoleToAccount.md | 2 +- .../Add-TeamViewerRoleToUserGroup.md | 2 +- .../Add-TeamViewerSsoExclusion.md | 2 +- .../Add-TeamViewerUserGroupMember.md | 2 +- docs/Cmdlets_help/Connect-TeamViewerApi.md | 2 +- docs/Cmdlets_help/Disconnect-TeamViewerApi.md | 2 +- .../Export-TeamViewerSystemInformation.md | 2 +- docs/Cmdlets_help/Get-TeamViewerAccount.md | 2 +- .../Get-TeamViewerConnectionReport.md | 2 +- docs/Cmdlets_help/Get-TeamViewerContact.md | 2 +- .../Get-TeamViewerCustomModuleId.md | 2 +- docs/Cmdlets_help/Get-TeamViewerDevice.md | 2 +- docs/Cmdlets_help/Get-TeamViewerEventLog.md | 2 +- docs/Cmdlets_help/Get-TeamViewerGroup.md | 2 +- docs/Cmdlets_help/Get-TeamViewerId.md | 2 +- .../Get-TeamViewerInstallationDirectory.md | 2 +- .../Cmdlets_help/Get-TeamViewerLogFilePath.md | 2 +- .../Get-TeamViewerManagedDevice.md | 2 +- .../Get-TeamViewerManagedGroup.md | 2 +- .../Get-TeamViewerManagementId.md | 2 +- docs/Cmdlets_help/Get-TeamViewerManager.md | 2 +- docs/Cmdlets_help/Get-TeamViewerPolicy.md | 2 +- .../Get-TeamViewerRoleAssignmentToAccount.md | 2 +- ...Get-TeamViewerRoleAssignmentToUserGroup.md | 2 +- docs/Cmdlets_help/Get-TeamViewerService.md | 2 +- docs/Cmdlets_help/Get-TeamViewerSsoDomain.md | 2 +- .../Get-TeamViewerSsoExclusion.md | 2 +- docs/Cmdlets_help/Get-TeamViewerUser.md | 2 +- docs/Cmdlets_help/Get-TeamViewerUserGroup.md | 2 +- .../Get-TeamViewerUserGroupMember.md | 2 +- docs/Cmdlets_help/Get-TeamViewerUserRole.md | 2 +- docs/Cmdlets_help/Get-TeamViewerVersion.md | 2 +- .../Invoke-TeamViewerPackageDownload.md | 2 +- docs/Cmdlets_help/Invoke-TeamViewerPing.md | 2 +- docs/Cmdlets_help/New-TeamViewerContact.md | 2 +- docs/Cmdlets_help/New-TeamViewerDevice.md | 2 +- docs/Cmdlets_help/New-TeamViewerGroup.md | 2 +- .../New-TeamViewerManagedGroup.md | 2 +- docs/Cmdlets_help/New-TeamViewerPolicy.md | 2 +- docs/Cmdlets_help/New-TeamViewerUser.md | 2 +- docs/Cmdlets_help/New-TeamViewerUserGroup.md | 2 +- docs/Cmdlets_help/New-TeamViewerUserRole.md | 2 +- docs/Cmdlets_help/Publish-TeamViewerGroup.md | 2 +- .../Remove-TeamViewerAssignment.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerContact.md | 2 +- .../Remove-TeamViewerCustomization.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerDevice.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerGroup.md | 2 +- .../Remove-TeamViewerManagedDevice.md | 2 +- ...emove-TeamViewerManagedDeviceManagement.md | 2 +- .../Remove-TeamViewerManagedGroup.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerManager.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerPSProxy.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerPolicy.md | 2 +- .../Remove-TeamViewerRoleFromAccount.md | 2 +- .../Remove-TeamViewerRoleFromUserGroup.md | 2 +- .../Remove-TeamViewerSsoExclusion.md | 2 +- docs/Cmdlets_help/Remove-TeamViewerUser.md | 2 +- .../Remove-TeamViewerUserGroup.md | 2 +- .../Remove-TeamViewerUserGroupMember.md | 2 +- .../Cmdlets_help/Remove-TeamViewerUserRole.md | 2 +- .../Cmdlets_help/Restart-TeamViewerService.md | 2 +- docs/Cmdlets_help/Set-TeamViewerAccount.md | 2 +- docs/Cmdlets_help/Set-TeamViewerDevice.md | 2 +- docs/Cmdlets_help/Set-TeamViewerGroup.md | 2 +- .../Set-TeamViewerManagedGroup.md | 2 +- docs/Cmdlets_help/Set-TeamViewerManager.md | 2 +- docs/Cmdlets_help/Set-TeamViewerPSProxy.md | 2 +- docs/Cmdlets_help/Set-TeamViewerPolicy.md | 2 +- docs/Cmdlets_help/Set-TeamViewerUser.md | 2 +- docs/Cmdlets_help/Set-TeamViewerUserGroup.md | 2 +- docs/Cmdlets_help/Set-TeamViewerUserRole.md | 2 +- docs/Cmdlets_help/Start-TeamViewerService.md | 2 +- docs/Cmdlets_help/Stop-TeamViewerService.md | 2 +- .../Test-TeamViewerConnectivity.md | 2 +- .../Test-TeamViewerInstallation.md | 2 +- .../Cmdlets_help/Unpublish-TeamViewerGroup.md | 2 +- 83 files changed, 84 insertions(+), 119 deletions(-) diff --git a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 index 697ad21..f88bc56 100644 --- a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 @@ -38,13 +38,6 @@ Describe 'Set-TeamViewerManagedDevice' { $body.teamviewerPolicyId | Should -Be '2871c013-3040-4969-9ba4-ce970f4375e8' } - It 'Should remove the managed device policy' { - Set-TeamViewerManagedDevice -ApiToken $testApiToken -Device $testDeviceId -RemovePolicy - $mockArgs.Body | Should -Not -BeNullOrEmpty - $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json - $body.teamviewerPolicyId | Should -Be '' - } - It 'Should update the managed device policy to the managed group' { Set-TeamViewerManagedDevice -ApiToken $testApiToken -Device $testDeviceId -ManagedGroup 'e579cfeb-0b29-4d91-9e81-2d9507f53ff8' $mockArgs.Body | Should -Not -BeNullOrEmpty @@ -52,14 +45,6 @@ Describe 'Set-TeamViewerManagedDevice' { $body.managedGroupId | Should -Be 'e579cfeb-0b29-4d91-9e81-2d9507f53ff8' } - It 'Should not be possible to set and remove the policy at the same time' { - { Set-TeamViewerManagedDevice ` - -ApiToken $testApiToken ` - -Device $testDeviceId ` - -Policy '2871c013-3040-4969-9ba4-ce970f4375e8' ` - -RemovePolicy } | Should -Throw - } - It 'Should not be possible to inherit and set a policy at the same time' { { Set-TeamViewerManagedDevice ` -ApiToken $testApiToken ` @@ -68,14 +53,6 @@ Describe 'Set-TeamViewerManagedDevice' { -ManagedGroup '6808db5b-f3c1-4e42-8168-3ac96f5d456e' } | Should -Throw } - It 'Should not be possible to inherit and remove a policy at the same time' { - { Set-TeamViewerManagedDevice ` - -ApiToken $testApiToken ` - -Device $testDeviceId ` - -ManagedGroup '2871c013-3040-4969-9ba4-ce970f4375e8' ` - -RemovePolicy } | Should -Throw - } - It 'Should not be possible to use "none" or "inherit" as values for policy' { { Set-TeamViewerManagedDevice ` -ApiToken $testApiToken ` diff --git a/docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 b/docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 index 62d415f..4370385 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 @@ -23,10 +23,7 @@ function Set-TeamViewerManagedDevice { [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] [Alias("ManagedGroupId")] [object] - $ManagedGroup, - - [switch] - $RemovePolicy + $ManagedGroup ) Begin { $body = @{} @@ -37,22 +34,13 @@ function Set-TeamViewerManagedDevice { if ($Policy) { $body['teamviewerPolicyId'] = $Policy | Resolve-TeamViewerPolicyId } - elseif ($RemovePolicy) { - $body['teamviewerPolicyId'] = "" - } elseif ($ManagedGroup) { $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId } - if ($Policy -And $RemovePolicy) { - $PSCmdlet.ThrowTerminatingError( - ("Parameters -Policy and -RemovePolicy cannot be used together." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - if (($Policy -or $RemovePolicy) -And $ManagedGroup) { + if ($Policy -And $ManagedGroup) { $PSCmdlet.ThrowTerminatingError( - ("The combination of parameters -Policy, -PolicyRemove and -ManagedGroup is not allowed." | ` + ("The combination of parameters -Policy and -ManagedGroup is not allowed." | ` ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } diff --git a/docs/Cmdlets_help/Add-TeamViewerAssignment.md b/docs/Cmdlets_help/Add-TeamViewerAssignment.md index af52fb1..873289f 100644 --- a/docs/Cmdlets_help/Add-TeamViewerAssignment.md +++ b/docs/Cmdlets_help/Add-TeamViewerAssignment.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerAssignment.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerCustomization.md b/docs/Cmdlets_help/Add-TeamViewerCustomization.md index a50eb3b..876c4dc 100644 --- a/docs/Cmdlets_help/Add-TeamViewerCustomization.md +++ b/docs/Cmdlets_help/Add-TeamViewerCustomization.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerCustomization.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md index bdb6f74..6d32343 100644 --- a/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Add-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerManager.md b/docs/Cmdlets_help/Add-TeamViewerManager.md index 0f855eb..2bbbeb0 100644 --- a/docs/Cmdlets_help/Add-TeamViewerManager.md +++ b/docs/Cmdlets_help/Add-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Add-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md b/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md index 5d1da9f..6eaa3ef 100644 --- a/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md +++ b/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md b/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md index 50dfcab..ce3dfa6 100644 --- a/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md +++ b/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md b/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md index e6c0197..29f9a0b 100644 --- a/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md +++ b/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md b/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md index 3ffcaef..227136f 100644 --- a/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md +++ b/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Connect-TeamViewerApi.md b/docs/Cmdlets_help/Connect-TeamViewerApi.md index fc3b872..015a8be 100644 --- a/docs/Cmdlets_help/Connect-TeamViewerApi.md +++ b/docs/Cmdlets_help/Connect-TeamViewerApi.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Connect-TeamViewerApi.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Connect-TeamViewerApi.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Disconnect-TeamViewerApi.md b/docs/Cmdlets_help/Disconnect-TeamViewerApi.md index 0243e3d..6c5f1e6 100644 --- a/docs/Cmdlets_help/Disconnect-TeamViewerApi.md +++ b/docs/Cmdlets_help/Disconnect-TeamViewerApi.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Disconnect-TeamViewerApi.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Disconnect-TeamViewerApi.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md b/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md index 417e50a..1eacf6e 100644 --- a/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md +++ b/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerAccount.md b/docs/Cmdlets_help/Get-TeamViewerAccount.md index 9ab3a95..2052426 100644 --- a/docs/Cmdlets_help/Get-TeamViewerAccount.md +++ b/docs/Cmdlets_help/Get-TeamViewerAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md b/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md index 8b92591..6e5923f 100644 --- a/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md +++ b/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerConnectionReport.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerContact.md b/docs/Cmdlets_help/Get-TeamViewerContact.md index 47bc1b2..233ca74 100644 --- a/docs/Cmdlets_help/Get-TeamViewerContact.md +++ b/docs/Cmdlets_help/Get-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md b/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md index cca477c..efe5c9e 100644 --- a/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md +++ b/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerDevice.md b/docs/Cmdlets_help/Get-TeamViewerDevice.md index 888ce76..cf40053 100644 --- a/docs/Cmdlets_help/Get-TeamViewerDevice.md +++ b/docs/Cmdlets_help/Get-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerEventLog.md b/docs/Cmdlets_help/Get-TeamViewerEventLog.md index f1026e2..072a2fd 100644 --- a/docs/Cmdlets_help/Get-TeamViewerEventLog.md +++ b/docs/Cmdlets_help/Get-TeamViewerEventLog.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerEventLog.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerEventLog.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerGroup.md b/docs/Cmdlets_help/Get-TeamViewerGroup.md index 0591504..1f248a9 100644 --- a/docs/Cmdlets_help/Get-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerId.md b/docs/Cmdlets_help/Get-TeamViewerId.md index 08762b5..912b0f5 100644 --- a/docs/Cmdlets_help/Get-TeamViewerId.md +++ b/docs/Cmdlets_help/Get-TeamViewerId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md b/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md index 79a212f..4ada3b1 100644 --- a/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md +++ b/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md b/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md index 0efa86b..33396a8 100644 --- a/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md +++ b/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerLogFilePath schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md index b8f4044..d214115 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md b/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md index 565e970..c4d44b3 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManagementId.md b/docs/Cmdlets_help/Get-TeamViewerManagementId.md index 9aa40da..f7629be 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManagementId.md +++ b/docs/Cmdlets_help/Get-TeamViewerManagementId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManagementId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManagementId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManager.md b/docs/Cmdlets_help/Get-TeamViewerManager.md index e56b062..2f608fa 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManager.md +++ b/docs/Cmdlets_help/Get-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerPolicy.md b/docs/Cmdlets_help/Get-TeamViewerPolicy.md index 9ff614c..143b190 100644 --- a/docs/Cmdlets_help/Get-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/Get-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md index 6657d4e..47d8ec0 100644 --- a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md +++ b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md index 0ddc527..abc39fc 100644 --- a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerService.md b/docs/Cmdlets_help/Get-TeamViewerService.md index cf09164..3d9ae9a 100644 --- a/docs/Cmdlets_help/Get-TeamViewerService.md +++ b/docs/Cmdlets_help/Get-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md b/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md index 0d4a7fc..5a5f4f5 100644 --- a/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md +++ b/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md b/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md index d4b8c39..cc841ca 100644 --- a/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md +++ b/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUser.md b/docs/Cmdlets_help/Get-TeamViewerUser.md index 72edf51..c20a735 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUser.md +++ b/docs/Cmdlets_help/Get-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUserGroup.md b/docs/Cmdlets_help/Get-TeamViewerUserGroup.md index 356186f..fb81750 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/Get-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-Get-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-Get-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md b/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md index 73513ed..c3e2334 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md +++ b/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUserRole.md b/docs/Cmdlets_help/Get-TeamViewerUserRole.md index b00c835..1fcf81a 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUserRole.md +++ b/docs/Cmdlets_help/Get-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerVersion.md b/docs/Cmdlets_help/Get-TeamViewerVersion.md index 2799057..9302e8a 100644 --- a/docs/Cmdlets_help/Get-TeamViewerVersion.md +++ b/docs/Cmdlets_help/Get-TeamViewerVersion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Get-TeamViewerVersion.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerVersion.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md b/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md index 9ad211e..51fa4ea 100644 --- a/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md +++ b/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Invoke-TeamViewerPing.md b/docs/Cmdlets_help/Invoke-TeamViewerPing.md index cfeab33..39f793d 100644 --- a/docs/Cmdlets_help/Invoke-TeamViewerPing.md +++ b/docs/Cmdlets_help/Invoke-TeamViewerPing.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Invoke-TeamViewerPing.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Invoke-TeamViewerPing.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerContact.md b/docs/Cmdlets_help/New-TeamViewerContact.md index c0d710d..a4a4f97 100644 --- a/docs/Cmdlets_help/New-TeamViewerContact.md +++ b/docs/Cmdlets_help/New-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerDevice.md b/docs/Cmdlets_help/New-TeamViewerDevice.md index d06f3fb..9527489 100644 --- a/docs/Cmdlets_help/New-TeamViewerDevice.md +++ b/docs/Cmdlets_help/New-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerGroup.md b/docs/Cmdlets_help/New-TeamViewerGroup.md index 2d67ee3..f58eccd 100644 --- a/docs/Cmdlets_help/New-TeamViewerGroup.md +++ b/docs/Cmdlets_help/New-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerManagedGroup.md b/docs/Cmdlets_help/New-TeamViewerManagedGroup.md index e5803ee..ad96a8f 100644 --- a/docs/Cmdlets_help/New-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/New-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerPolicy.md b/docs/Cmdlets_help/New-TeamViewerPolicy.md index 6970c1a..36c2e21 100644 --- a/docs/Cmdlets_help/New-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/New-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerUser.md b/docs/Cmdlets_help/New-TeamViewerUser.md index 05793e1..59193f1 100644 --- a/docs/Cmdlets_help/New-TeamViewerUser.md +++ b/docs/Cmdlets_help/New-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerUserGroup.md b/docs/Cmdlets_help/New-TeamViewerUserGroup.md index 53ec43a..a316b33 100644 --- a/docs/Cmdlets_help/New-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/New-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/New-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerUserRole.md b/docs/Cmdlets_help/New-TeamViewerUserRole.md index 1881be5..f6deb32 100644 --- a/docs/Cmdlets_help/New-TeamViewerUserRole.md +++ b/docs/Cmdlets_help/New-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Publish-TeamViewerGroup.md b/docs/Cmdlets_help/Publish-TeamViewerGroup.md index 5e692c9..db62dec 100644 --- a/docs/Cmdlets_help/Publish-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Publish-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Publish-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Publish-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerAssignment.md b/docs/Cmdlets_help/Remove-TeamViewerAssignment.md index ac6e507..5635c9a 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerAssignment.md +++ b/docs/Cmdlets_help/Remove-TeamViewerAssignment.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerAssignment.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerContact.md b/docs/Cmdlets_help/Remove-TeamViewerContact.md index ed944d3..f9a6981 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerContact.md +++ b/docs/Cmdlets_help/Remove-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerCustomization.md b/docs/Cmdlets_help/Remove-TeamViewerCustomization.md index 69a56cb..d42f16c 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerCustomization.md +++ b/docs/Cmdlets_help/Remove-TeamViewerCustomization.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerCustomization.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerDevice.md b/docs/Cmdlets_help/Remove-TeamViewerDevice.md index caf9dc8..5cb101e 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerDevice.md +++ b/docs/Cmdlets_help/Remove-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerGroup.md b/docs/Cmdlets_help/Remove-TeamViewerGroup.md index 639ae92..c1aa0b2 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md index 8579a4d..d205174 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md b/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md index 7bc797a..ebfdf98 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md b/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md index e1f1801..75be21e 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManager.md b/docs/Cmdlets_help/Remove-TeamViewerManager.md index a1fce2e..996e3b5 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManager.md +++ b/docs/Cmdlets_help/Remove-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md b/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md index 7f514e1..c4c3200 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md +++ b/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerPSProxy schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerPolicy.md b/docs/Cmdlets_help/Remove-TeamViewerPolicy.md index 45337fd..26ed60f 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/Remove-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md b/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md index 43a4ef5..cc8dc6b 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md +++ b/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md b/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md index 4a8446a..e88378b 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md b/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md index a0ee123..63cc616 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md +++ b/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerUser.md b/docs/Cmdlets_help/Remove-TeamViewerUser.md index e37553e..3fc0094 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUser.md +++ b/docs/Cmdlets_help/Remove-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md b/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md index 796441c..a78d4fd 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md b/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md index ebad7dc..281e950 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md +++ b/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserRole.md b/docs/Cmdlets_help/Remove-TeamViewerUserRole.md index 2edf25a..e2b0c13 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUserRole.md +++ b/docs/Cmdlets_help/Remove-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Restart-TeamViewerService.md b/docs/Cmdlets_help/Restart-TeamViewerService.md index 95dd02f..f354e28 100644 --- a/docs/Cmdlets_help/Restart-TeamViewerService.md +++ b/docs/Cmdlets_help/Restart-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Restart-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Restart-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerAccount.md b/docs/Cmdlets_help/Set-TeamViewerAccount.md index 96b0b00..aefa72a 100644 --- a/docs/Cmdlets_help/Set-TeamViewerAccount.md +++ b/docs/Cmdlets_help/Set-TeamViewerAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerDevice.md b/docs/Cmdlets_help/Set-TeamViewerDevice.md index 30ae954..d6e77ca 100644 --- a/docs/Cmdlets_help/Set-TeamViewerDevice.md +++ b/docs/Cmdlets_help/Set-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerGroup.md b/docs/Cmdlets_help/Set-TeamViewerGroup.md index 6554c40..c9c8e45 100644 --- a/docs/Cmdlets_help/Set-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Set-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md b/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md index cfee11c..21d6bd4 100644 --- a/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md +++ b/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerManager.md b/docs/Cmdlets_help/Set-TeamViewerManager.md index 8a7b7a4..4914428 100644 --- a/docs/Cmdlets_help/Set-TeamViewerManager.md +++ b/docs/Cmdlets_help/Set-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerPSProxy.md b/docs/Cmdlets_help/Set-TeamViewerPSProxy.md index e87029c..fedd0cb 100644 --- a/docs/Cmdlets_help/Set-TeamViewerPSProxy.md +++ b/docs/Cmdlets_help/Set-TeamViewerPSProxy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerPSProxy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerPolicy.md b/docs/Cmdlets_help/Set-TeamViewerPolicy.md index 7ad75ec..2d0915f 100644 --- a/docs/Cmdlets_help/Set-TeamViewerPolicy.md +++ b/docs/Cmdlets_help/Set-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerUser.md b/docs/Cmdlets_help/Set-TeamViewerUser.md index 619491d..8b49745 100644 --- a/docs/Cmdlets_help/Set-TeamViewerUser.md +++ b/docs/Cmdlets_help/Set-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerUserGroup.md b/docs/Cmdlets_help/Set-TeamViewerUserGroup.md index ea7e283..bc9b69d 100644 --- a/docs/Cmdlets_help/Set-TeamViewerUserGroup.md +++ b/docs/Cmdlets_help/Set-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Set-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerUserRole.md b/docs/Cmdlets_help/Set-TeamViewerUserRole.md index f08939f..95ff406 100644 --- a/docs/Cmdlets_help/Set-TeamViewerUserRole.md +++ b/docs/Cmdlets_help/Set-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Start-TeamViewerService.md b/docs/Cmdlets_help/Start-TeamViewerService.md index a5f3907..c672810 100644 --- a/docs/Cmdlets_help/Start-TeamViewerService.md +++ b/docs/Cmdlets_help/Start-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Start-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Start-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Stop-TeamViewerService.md b/docs/Cmdlets_help/Stop-TeamViewerService.md index 0aa28b8..26a8f0b 100644 --- a/docs/Cmdlets_help/Stop-TeamViewerService.md +++ b/docs/Cmdlets_help/Stop-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Stop-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Stop-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Test-TeamViewerConnectivity.md b/docs/Cmdlets_help/Test-TeamViewerConnectivity.md index 8fbc5cf..5e5e4b0 100644 --- a/docs/Cmdlets_help/Test-TeamViewerConnectivity.md +++ b/docs/Cmdlets_help/Test-TeamViewerConnectivity.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Test-TeamViewerConnectivity.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Test-TeamViewerConnectivity.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Test-TeamViewerInstallation.md b/docs/Cmdlets_help/Test-TeamViewerInstallation.md index 465c41a..3b36d7f 100644 --- a/docs/Cmdlets_help/Test-TeamViewerInstallation.md +++ b/docs/Cmdlets_help/Test-TeamViewerInstallation.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Test-TeamViewerInstallation.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Test-TeamViewerInstallation.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md b/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md index 0996292..887e2ab 100644 --- a/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md +++ b/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Cmdlets_help/Unpublish-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md schema: 2.0.0 --- From 1ed42a34d833ddca866dce2c13a298b8520d2e98 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Tue, 19 Sep 2023 15:32:21 +0200 Subject: [PATCH 035/110] Updated help file for Set-TeamViewerManagedDevice and changelog --- CHANGELOG.md | 2 ++ .../Set-TeamViewerManagedDevice.md | 30 +------------------ 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6489fd5..81db365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,13 @@ -Added `Export-TeamViewerSystemInformation` to create zip file for support. -Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. -Added `Get-TeamViewerInstallationDirectory` to return installation directory. + -Added `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. ### Changed -Extended `Invoke-TeamViewerPackageDownload` with MSI package type. -Folder structure modified. + -`-RemovePolicy` switched removed from `Set-TeamViewerManagedDevice`. ### Fixed diff --git a/docs/Cmdlets_help/Set-TeamViewerManagedDevice.md b/docs/Cmdlets_help/Set-TeamViewerManagedDevice.md index 1cc2bbb..3ee7414 100644 --- a/docs/Cmdlets_help/Set-TeamViewerManagedDevice.md +++ b/docs/Cmdlets_help/Set-TeamViewerManagedDevice.md @@ -15,7 +15,7 @@ Change properties of a TeamViewer managed device. ```powershell Set-TeamViewerManagedDevice [-ApiToken] [-Device] [[-Name] ] - [[-Policy] ] [-RemovePolicy] [[-ManagedGroup] ] [-WhatIf] [-Confirm] [] + [[-Policy] ] [[-ManagedGroup] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -49,14 +49,6 @@ Sets the policy of the device. ### Example 3 -```powershell -PS /> Set-TeamViewerManagedDevice -Device '33a2e2e1-27ef-43e2-a175-f97ee0344033' -RemovePolicy -``` - -Removes the TeamViewer policy of the device. - -### Example 3 - ```powershell PS /> Set-TeamViewerManagedDevice -Device '33a2e2e1-27ef-43e2-a175-f97ee0344033' -ManagedGroup '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' ``` @@ -137,8 +129,6 @@ Object that can be used to identify the policy. This can either be the policy ID (as string or GUID) or a policy object that has been received using other module functions. -Cannot be used in conjunction with the `-RemovePolicy` parameter. - ```yaml Type: Object Parameter Sets: (All) @@ -151,24 +141,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -RemovePolicy - -Removes the policy from the managed device. - -Cannot be used in conjunction with the `-Policy` parameter. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -ManagedGroup Object that can be used to identify the managed group. From 5f4166fd2f8e8fbf64eef9a0ab0840b41b1a70f5 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Tue, 19 Sep 2023 15:38:41 +0200 Subject: [PATCH 036/110] Changelog updated --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81db365..64affa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ -Extended `Invoke-TeamViewerPackageDownload` with MSI package type. -Folder structure modified. - -`-RemovePolicy` switched removed from `Set-TeamViewerManagedDevice`. + -`-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. ### Fixed From 58359ec7e1442eca79799bc4b2705ede8a80e7b0 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Wed, 20 Sep 2023 09:37:49 +0200 Subject: [PATCH 037/110] Workflow updated --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index 27cb284..cd0427c 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Include your own basic security rules. Removing this option will run all the rules - # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' + # Exclude your own basic security rules. Removing this option will run all the rules + excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index ff69da6..8b5fc43 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index 11b03b6..b943a5c 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh From ede309209f253d7c0c8d0b2dc938c389d1f86185 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV Date: Wed, 20 Sep 2023 09:49:36 +0200 Subject: [PATCH 038/110] PSAvoidTrailingWhitespace warning fixed --- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 --- docs/Cmdlets/Private/Get-ClientId.ps1 | 1 - docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 - docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index 0d6dec6..d6ca0ac 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,7 +9,6 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId - Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -20,10 +19,8 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { - It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index 5312ba5..eedf9f6 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,6 +7,5 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } - return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index 58cd1f3..e560a5a 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index faffda7..f053140 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,7 +4,6 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index aecc984..d8dbae1 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,7 +34,6 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } - Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From 4c371c8c2016d2a7748e49756231ebd5d5e84f9e Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:03:04 +0200 Subject: [PATCH 039/110] Revert "Merge pull request #38 from karthickgandhiTV/main" This reverts commit 7e620256404ebe50af0689b7c829c5399b10f737, reversing changes made to 4d70b5dd4990b2ce361257c42e6c8c1e40dbaa15. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 +++ docs/Cmdlets/Private/Get-ClientId.ps1 | 1 + docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 + docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 + 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index cd0427c..27cb284 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Exclude your own basic security rules. Removing this option will run all the rules - excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' + # Include your own basic security rules. Removing this option will run all the rules + # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 8b5fc43..ff69da6 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index b943a5c..11b03b6 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index d6ca0ac..0d6dec6 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,6 +9,7 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId + Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -19,8 +20,10 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { + It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index eedf9f6..5312ba5 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,5 +7,6 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } + return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index e560a5a..58cd1f3 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index f053140..faffda7 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,6 +4,7 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index d8dbae1..aecc984 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,6 +34,7 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } + Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From f36028e7c6fb5a5c41062b32da457ef32b55a935 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:04:43 +0200 Subject: [PATCH 040/110] Revert "Revert "Merge pull request #38 from karthickgandhiTV/main"" This reverts commit 4c371c8c2016d2a7748e49756231ebd5d5e84f9e. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 --- docs/Cmdlets/Private/Get-ClientId.ps1 | 1 - docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 - docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 - 8 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index 27cb284..cd0427c 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Include your own basic security rules. Removing this option will run all the rules - # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' + # Exclude your own basic security rules. Removing this option will run all the rules + excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index ff69da6..8b5fc43 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index 11b03b6..b943a5c 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index 0d6dec6..d6ca0ac 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,7 +9,6 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId - Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -20,10 +19,8 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { - It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index 5312ba5..eedf9f6 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,6 +7,5 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } - return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index 58cd1f3..e560a5a 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index faffda7..f053140 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,7 +4,6 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index aecc984..d8dbae1 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,7 +34,6 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } - Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From bfb4e2594b6f3425c83582162e09012190c3f614 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:04:51 +0200 Subject: [PATCH 041/110] Revert "Merge pull request #38 from karthickgandhiTV/main" This reverts commit 7e620256404ebe50af0689b7c829c5399b10f737, reversing changes made to 4d70b5dd4990b2ce361257c42e6c8c1e40dbaa15. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 +++ docs/Cmdlets/Private/Get-ClientId.ps1 | 1 + docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 + docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 + 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index cd0427c..27cb284 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Exclude your own basic security rules. Removing this option will run all the rules - excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' + # Include your own basic security rules. Removing this option will run all the rules + # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 8b5fc43..ff69da6 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index b943a5c..11b03b6 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index d6ca0ac..0d6dec6 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,6 +9,7 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId + Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -19,8 +20,10 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { + It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index eedf9f6..5312ba5 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,5 +7,6 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } + return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index e560a5a..58cd1f3 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index f053140..faffda7 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,6 +4,7 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index d8dbae1..aecc984 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,6 +34,7 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } + Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From c6ff8f7e38e35294076b3d95d80535259a7d91a5 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:41:00 +0200 Subject: [PATCH 042/110] Update CHANGELOG.md. --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64affa1..6545dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,12 @@ ### Fixed -Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. - + +## 1.5.2 (2023-09-18) + +- Remove-TeamViewerPolicyFromManagedDevice has been added. +- ManagedGroupId parameter has been added to Set-TeamViewerManagedDevice. + ## 1.5.1 (2023-07-18) - Improved `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` From ecccff19525b35eb244b83eda5fdb1a44e6c75e7 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:55:59 +0200 Subject: [PATCH 043/110] Revert "Update CHANGELOG.md." This reverts commit c6ff8f7e38e35294076b3d95d80535259a7d91a5. --- CHANGELOG.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6545dc3..64affa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,12 +22,7 @@ ### Fixed -Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. - -## 1.5.2 (2023-09-18) - -- Remove-TeamViewerPolicyFromManagedDevice has been added. -- ManagedGroupId parameter has been added to Set-TeamViewerManagedDevice. - + ## 1.5.1 (2023-07-18) - Improved `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` From 45302ce53259ce4f0e5bca61932a8b3fcd2039dd Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:56:03 +0200 Subject: [PATCH 044/110] Revert "Revert "Merge pull request #38 from karthickgandhiTV/main"" This reverts commit bfb4e2594b6f3425c83582162e09012190c3f614. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 --- docs/Cmdlets/Private/Get-ClientId.ps1 | 1 - docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 - docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 - 8 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index 27cb284..cd0427c 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Include your own basic security rules. Removing this option will run all the rules - # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' + # Exclude your own basic security rules. Removing this option will run all the rules + excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index ff69da6..8b5fc43 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index 11b03b6..b943a5c 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index 0d6dec6..d6ca0ac 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,7 +9,6 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId - Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -20,10 +19,8 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { - It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index 5312ba5..eedf9f6 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,6 +7,5 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } - return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index 58cd1f3..e560a5a 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index faffda7..f053140 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,7 +4,6 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index aecc984..d8dbae1 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,7 +34,6 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } - Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From e60d0dfdd86ed6c0477c599b6ea42cd7af92224e Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:56:06 +0200 Subject: [PATCH 045/110] Revert "Revert "Revert "Merge pull request #38 from karthickgandhiTV/main""" This reverts commit f36028e7c6fb5a5c41062b32da457ef32b55a935. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 +++ docs/Cmdlets/Private/Get-ClientId.ps1 | 1 + docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 + docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 + 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index cd0427c..27cb284 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Exclude your own basic security rules. Removing this option will run all the rules - excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' + # Include your own basic security rules. Removing this option will run all the rules + # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 8b5fc43..ff69da6 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index b943a5c..11b03b6 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index d6ca0ac..0d6dec6 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,6 +9,7 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId + Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -19,8 +20,10 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { + It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index eedf9f6..5312ba5 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,5 +7,6 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } + return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index e560a5a..58cd1f3 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index f053140..faffda7 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,6 +4,7 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index d8dbae1..aecc984 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,6 +34,7 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } + Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From d870a714d2d4333372a77af26863db2113c493f0 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:56:10 +0200 Subject: [PATCH 046/110] Revert "Revert "Merge pull request #38 from karthickgandhiTV/main"" This reverts commit 4c371c8c2016d2a7748e49756231ebd5d5e84f9e. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 --- docs/Cmdlets/Private/Get-ClientId.ps1 | 1 - docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 - docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 - 8 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index 27cb284..cd0427c 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Include your own basic security rules. Removing this option will run all the rules - # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' + # Exclude your own basic security rules. Removing this option will run all the rules + excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index ff69da6..8b5fc43 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index 11b03b6..b943a5c 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index 0d6dec6..d6ca0ac 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,7 +9,6 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId - Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -20,10 +19,8 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { - It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index 5312ba5..eedf9f6 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,6 +7,5 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } - return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index 58cd1f3..e560a5a 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index faffda7..f053140 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,7 +4,6 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index aecc984..d8dbae1 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,7 +34,6 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } - Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod ` From ae0516228d2c9fc6545c5718d03ef92fded9cdd3 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:57:54 +0200 Subject: [PATCH 047/110] Update CHANGELOG.md for completeness. --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64affa1..5831d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,12 @@ ### Fixed -Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. - + +## 1.5.2 (2023-09-18) + +- Remove-TeamViewerPolicyFromManagedDevice has been added. +- ManagedGroupId parameter has been added to Set-TeamViewerManagedDevice. + ## 1.5.1 (2023-07-18) - Improved `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` From 2f5a559ba73905e34e539997b13489d1b402ed9c Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 28 Sep 2023 19:28:55 +0200 Subject: [PATCH 048/110] Move Cmdlets from Docs to root --- .github/workflows/ci.yml | 4 +- .github/workflows/publish_testing.yml | 33 - Build/New-Package.ps1 | 86 +- .../Private/Add-Registry.ps1 | 0 .../Private/ConvertTo-DateTime.ps1 | 0 .../Private/ConvertTo-ErrorRecord.ps1 | 0 .../Private/ConvertTo-TeamViewerAccount.ps1 | 0 .../ConvertTo-TeamViewerAuditEvent.ps1 | 0 .../ConvertTo-TeamViewerConnectionReport.ps1 | 0 .../Private/ConvertTo-TeamViewerContact.ps1 | 0 .../Private/ConvertTo-TeamViewerDevice.ps1 | 0 .../Private/ConvertTo-TeamViewerGroup.ps1 | 0 .../ConvertTo-TeamViewerGroupShare.ps1 | 0 .../ConvertTo-TeamViewerManagedDevice.ps1 | 0 .../ConvertTo-TeamViewerManagedGroup.ps1 | 0 .../Private/ConvertTo-TeamViewerManager.ps1 | 0 .../Private/ConvertTo-TeamViewerPolicy.ps1 | 0 .../Private/ConvertTo-TeamViewerRestError.ps1 | 0 .../ConvertTo-TeamViewerRoleAssignedUser.ps1 | 0 ...vertTo-TeamViewerRoleAssignedUserGroup.ps1 | 0 .../Private/ConvertTo-TeamViewerSsoDomain.ps1 | 0 .../Private/ConvertTo-TeamViewerUser.ps1 | 0 .../Private/ConvertTo-TeamViewerUserGroup.ps1 | 0 .../ConvertTo-TeamViewerUserGroupMember.ps1 | 0 .../Private/ConvertTo-TeamViewerUserRole.ps1 | 0 .../Private/Get-ClientId.ps1 | 0 .../Private/Get-HostFile.ps1 | 0 .../Private/Get-InstalledSoftware.ps1 | 0 .../Private/Get-IpConfig.ps1 | 0 .../Private/Get-MSInfo32.ps1 | 0 .../Private/Get-NSLookUpData.ps1 | 0 .../Private/Get-OperatingSystem.ps1 | 0 .../Private/Get-RegistryPath.ps1 | 0 .../Private/Get-RouteTable.ps1 | 0 .../Private/Get-TSCDirectoryFile.ps1 | 0 .../Private/Get-TSCSearchDirectory.ps1 | 0 .../Private/Get-TeamViewerApiUri.ps1 | 0 .../Get-TeamViewerLinuxGlobalConfig.ps1 | 0 .../Private/Get-TeamViewerRegKeyPath.ps1 | 0 .../Private/Get-TeamViewerServiceName.ps1 | 0 .../Get-TypeAndValueOfRegistryValue.ps1 | 0 .../Private/Invoke-ExternalCommand.ps1 | 0 .../Private/Invoke-TeamViewerRestMethod.ps1 | 0 .../Private/Resolve-AssignmentErrorCode.ps1 | 0 .../Resolve-CustomizationErrorCode.ps1 | 0 .../Private/Resolve-TeamViewerContactId.ps1 | 0 .../Private/Resolve-TeamViewerDeviceId.ps1 | 0 .../Private/Resolve-TeamViewerGroupId.ps1 | 0 .../Private/Resolve-TeamViewerLanguage.ps1 | 0 .../Resolve-TeamViewerManagedDeviceId.ps1 | 0 .../Resolve-TeamViewerManagedGroupId.ps1 | 0 .../Private/Resolve-TeamViewerManagerId.ps1 | 0 .../Private/Resolve-TeamViewerPolicyId.ps1 | 0 .../Private/Resolve-TeamViewerSsoDomainId.ps1 | 0 .../Private/Resolve-TeamViewerUserEmail.ps1 | 0 .../Private/Resolve-TeamViewerUserGroupId.ps1 | 0 .../Resolve-TeamViewerUserGroupMemberId.ps1 | 0 .../Private/Resolve-TeamViewerUserId.ps1 | 0 .../Private/Resolve-TeamViewerUserRoleId.ps1 | 0 .../Private/Test-TcpConnection.ps1 | 0 .../Private/Test-TeamViewer32on64.ps1 | 0 .../Public/Add-TeamViewerAssignment.ps1 | 0 .../Public/Add-TeamViewerCustomization.ps1 | 0 .../Public/Add-TeamViewerManagedDevice.ps1 | 0 .../Public/Add-TeamViewerManager.ps1 | 0 .../Public/Add-TeamViewerRoleToAccount.ps1 | 0 .../Public/Add-TeamViewerRoleToUserGroup.ps1 | 0 .../Public/Add-TeamViewerSsoExclusion.ps1 | 0 .../Public/Add-TeamViewerUserGroupMember.ps1 | 0 .../Public/Connect-TeamViewerApi.ps1 | 0 .../Public/Disconnect-TeamViewerApi.ps1 | 0 .../Export-TeamViewerSystemInformation.ps1 | 0 .../Public/Get-TeamViewerAccount.ps1 | 0 .../Public/Get-TeamViewerConnectionReport.ps1 | 0 .../Public/Get-TeamViewerContact.ps1 | 0 .../Public/Get-TeamViewerCustomModuleId.ps1 | 0 .../Public/Get-TeamViewerDevice.ps1 | 0 .../Public/Get-TeamViewerEventLog.ps1 | 0 .../Public/Get-TeamViewerGroup.ps1 | 0 .../Public/Get-TeamViewerId.ps1 | 0 .../Get-TeamViewerInstallationDirectory.ps1 | 0 .../Public/Get-TeamViewerLogFilePath.ps1 | 0 .../Public/Get-TeamViewerManagedDevice.ps1 | 0 .../Public/Get-TeamViewerManagedGroup.ps1 | 0 .../Public/Get-TeamViewerManagementId.ps1 | 0 .../Public/Get-TeamViewerManager.ps1 | 0 .../Public/Get-TeamViewerPolicy.ps1 | 0 .../Get-TeamViewerRoleAssignmentToAccount.ps1 | 0 ...et-TeamViewerRoleAssignmentToUserGroup.ps1 | 0 .../Public/Get-TeamViewerService.ps1 | 0 .../Public/Get-TeamViewerSsoDomain.ps1 | 0 .../Public/Get-TeamViewerSsoExclusion.ps1 | 0 .../Public/Get-TeamViewerUser.ps1 | 0 .../Public/Get-TeamViewerUserGroup.ps1 | 0 .../Public/Get-TeamViewerUserGroupMember.ps1 | 0 .../Public/Get-TeamViewerUserRole.ps1 | 0 .../Public/Get-TeamViewerVersion.ps1 | 0 .../Invoke-TeamViewerPackageDownload.ps1 | 0 .../Public/Invoke-TeamViewerPing.ps1 | 0 .../Public/New-TeamViewerContact.ps1 | 0 .../Public/New-TeamViewerDevice.ps1 | 0 .../Public/New-TeamViewerGroup.ps1 | 0 .../Public/New-TeamViewerManagedGroup.ps1 | 0 .../Public/New-TeamViewerPolicy.ps1 | 0 .../Public/New-TeamViewerUser.ps1 | 0 .../Public/New-TeamViewerUserGroup.ps1 | 0 .../Public/New-TeamViewerUserRole.ps1 | 0 .../Public/Publish-TeamViewerGroup.ps1 | 0 .../Public/Remove-TeamViewerAssignment.ps1 | 0 .../Public/Remove-TeamViewerContact.ps1 | 0 .../Public/Remove-TeamViewerCustomization.ps1 | 0 .../Public/Remove-TeamViewerDevice.ps1 | 0 .../Public/Remove-TeamViewerGroup.ps1 | 0 .../Public/Remove-TeamViewerManagedDevice.ps1 | 0 ...move-TeamViewerManagedDeviceManagement.ps1 | 0 .../Public/Remove-TeamViewerManagedGroup.ps1 | 0 .../Public/Remove-TeamViewerManager.ps1 | 0 .../Public/Remove-TeamViewerPSProxy.ps1 | 0 .../Public/Remove-TeamViewerPolicy.ps1 | 0 ...move-TeamViewerPolicyFromManagedDevice.ps1 | 0 .../Remove-TeamViewerRoleFromAccount.ps1 | 0 .../Remove-TeamViewerRoleFromUserGroup.ps1 | 0 .../Public/Remove-TeamViewerSsoExclusion.ps1 | 0 .../Public/Remove-TeamViewerUser.ps1 | 0 .../Public/Remove-TeamViewerUserGroup.ps1 | 0 .../Remove-TeamViewerUserGroupMember.ps1 | 0 .../Public/Remove-TeamViewerUserRole.ps1 | 0 .../Public/Restart-TeamViewerService.ps1 | 0 .../Public/Set-TeamViewerAPIUri.ps1 | 0 .../Public/Set-TeamViewerAccount.ps1 | 0 .../Public/Set-TeamViewerDevice.ps1 | 0 .../Public/Set-TeamViewerGroup.ps1 | 0 .../Public/Set-TeamViewerManagedDevice.ps1 | 0 .../Public/Set-TeamViewerManagedGroup.ps1 | 0 .../Public/Set-TeamViewerManager.ps1 | 0 .../Public/Set-TeamViewerPSProxy.ps1 | 0 .../Public/Set-TeamViewerPolicy.ps1 | 0 .../Public/Set-TeamViewerUser.ps1 | 0 .../Public/Set-TeamViewerUserGroup.ps1 | 0 .../Public/Set-TeamViewerUserRole.ps1 | 0 .../Public/Start-TeamViewerService.ps1 | 0 .../Public/Stop-TeamViewerService.ps1 | 0 .../Public/Test-TeamViewerConnectivity.ps1 | 0 .../Public/Test-TeamViewerInstallation.ps1 | 0 .../Public/Unpublish-TeamViewerGroup.ps1 | 0 {docs => Cmdlets}/TeamViewerPS.Types.ps1 | 0 {docs => Cmdlets}/TeamViewerPS.format.ps1xml | 0 {docs => Cmdlets}/TeamViewerPS.psd1 | 4 +- Cmdlets/TeamViewerPS.psm1 | 5849 +++++++++++++++++ {docs => Cmdlets}/about_TeamViewerPS.md | 0 .../Help}/Add-TeamViewerAssignment.md | 2 +- .../Help}/Add-TeamViewerCustomization.md | 2 +- .../Help}/Add-TeamViewerManagedDevice.md | 2 +- .../Help}/Add-TeamViewerManager.md | 4 +- .../Help}/Add-TeamViewerRoleToAccount.md | 2 +- .../Help}/Add-TeamViewerRoleToUserGroup.md | 2 +- .../Help}/Add-TeamViewerSsoExclusion.md | 4 +- .../Help}/Add-TeamViewerUserGroupMember.md | 2 +- .../Help}/Connect-TeamViewerApi.md | 2 +- .../Help}/Disconnect-TeamViewerApi.md | 2 +- .../Export-TeamViewerSystemInformation.md | 2 +- .../Help}/Get-TeamViewerAccount.md | 2 +- .../Help}/Get-TeamViewerConnectionReport.md | 2 +- .../Help}/Get-TeamViewerContact.md | 2 +- .../Help}/Get-TeamViewerCustomModuleId.md | 2 +- .../Help}/Get-TeamViewerDevice.md | 2 +- .../Help}/Get-TeamViewerEventLog.md | 2 +- .../Help}/Get-TeamViewerGroup.md | 2 +- .../Help}/Get-TeamViewerId.md | 2 +- .../Get-TeamViewerInstallationDirectory.md | 2 +- .../Help}/Get-TeamViewerLogFilePath.md | 2 +- .../Help}/Get-TeamViewerManagedDevice.md | 2 +- .../Help}/Get-TeamViewerManagedGroup.md | 2 +- .../Help}/Get-TeamViewerManagementId.md | 2 +- .../Help}/Get-TeamViewerManager.md | 2 +- .../Help}/Get-TeamViewerPolicy.md | 2 +- .../Get-TeamViewerRoleAssignmentToAccount.md | 2 +- ...Get-TeamViewerRoleAssignmentToUserGroup.md | 2 +- .../Help}/Get-TeamViewerService.md | 2 +- .../Help}/Get-TeamViewerSsoDomain.md | 2 +- .../Help}/Get-TeamViewerSsoExclusion.md | 2 +- .../Help}/Get-TeamViewerUser.md | 2 +- .../Help}/Get-TeamViewerUserGroup.md | 2 +- .../Help}/Get-TeamViewerUserGroupMember.md | 2 +- .../Help}/Get-TeamViewerUserRole.md | 2 +- .../Help}/Get-TeamViewerVersion.md | 2 +- .../Help}/Invoke-TeamViewerPackageDownload.md | 2 +- .../Help}/Invoke-TeamViewerPing.md | 2 +- .../Help}/New-TeamViewerContact.md | 2 +- .../Help}/New-TeamViewerDevice.md | 2 +- .../Help}/New-TeamViewerGroup.md | 2 +- .../Help}/New-TeamViewerManagedGroup.md | 2 +- .../Help}/New-TeamViewerPolicy.md | 2 +- .../Help}/New-TeamViewerUser.md | 2 +- .../Help}/New-TeamViewerUserGroup.md | 2 +- .../Help}/New-TeamViewerUserRole.md | 2 +- .../Help}/Publish-TeamViewerGroup.md | 2 +- .../Help}/Remove-TeamViewerAssignment.md | 2 +- .../Help}/Remove-TeamViewerContact.md | 2 +- .../Help}/Remove-TeamViewerCustomization.md | 2 +- .../Help}/Remove-TeamViewerDevice.md | 2 +- .../Help}/Remove-TeamViewerGroup.md | 2 +- .../Help}/Remove-TeamViewerManagedDevice.md | 2 +- ...emove-TeamViewerManagedDeviceManagement.md | 2 +- .../Help}/Remove-TeamViewerManagedGroup.md | 2 +- .../Help}/Remove-TeamViewerManager.md | 2 +- .../Help}/Remove-TeamViewerPSProxy.md | 2 +- .../Help}/Remove-TeamViewerPolicy.md | 2 +- ...emove-TeamViewerPolicyFromManagedDevice.md | 0 .../Help}/Remove-TeamViewerRoleFromAccount.md | 2 +- .../Remove-TeamViewerRoleFromUserGroup.md | 2 +- .../Help}/Remove-TeamViewerSsoExclusion.md | 4 +- .../Help}/Remove-TeamViewerUser.md | 3 +- .../Help}/Remove-TeamViewerUserGroup.md | 2 +- .../Help}/Remove-TeamViewerUserGroupMember.md | 2 +- .../Help}/Remove-TeamViewerUserRole.md | 2 +- .../Help}/Restart-TeamViewerService.md | 2 +- .../Help}/Set-TeamViewerAccount.md | 2 +- .../Help}/Set-TeamViewerDevice.md | 2 +- .../Help}/Set-TeamViewerGroup.md | 2 +- .../Help}/Set-TeamViewerManagedDevice.md | 0 .../Help}/Set-TeamViewerManagedGroup.md | 2 +- .../Help}/Set-TeamViewerManager.md | 2 +- .../Help}/Set-TeamViewerPSProxy.md | 2 +- .../Help}/Set-TeamViewerPolicy.md | 2 +- .../Help}/Set-TeamViewerUser.md | 2 +- .../Help}/Set-TeamViewerUserGroup.md | 2 +- .../Help}/Set-TeamViewerUserRole.md | 2 +- .../Help}/Start-TeamViewerService.md | 2 +- .../Help}/Stop-TeamViewerService.md | 2 +- .../Help}/Test-TeamViewerConnectivity.md | 2 +- .../Help}/Test-TeamViewerInstallation.md | 2 +- .../Help}/Unpublish-TeamViewerGroup.md | 2 +- .../Public/Add-TeamViewerAssignment.Tests.ps1 | 10 +- .../Add-TeamViewerCustomization.Tests.ps1 | 8 +- .../Add-TeamViewerManagedDevice.Tests.ps1 | 4 +- Tests/Public/Add-TeamViewerManager.Tests.ps1 | 4 +- .../Add-TeamViewerRoleToAccount.Tests.ps1 | 4 +- .../Add-TeamViewerRoleToUserGroup.Tests.ps1 | 4 +- .../Add-TeamViewerSsoExclusion.Tests.ps1 | 4 +- .../Add-TeamViewerUserGroupMember.Tests.ps1 | 4 +- Tests/Public/Connect-TeamViewerApi.Tests.ps1 | 6 +- .../Public/Disconnect-TeamViewerApi.Tests.ps1 | 2 +- ...port-TeamViewerSystemInformation.Tests.ps1 | 8 +- Tests/Public/Get-TeamViewerAccount.Tests.ps1 | 4 +- .../Get-TeamViewerConnectionReport.Tests.ps1 | 8 +- Tests/Public/Get-TeamViewerContact.Tests.ps1 | 4 +- .../Get-TeamViewerCustomModuleId.Tests.ps1 | 8 +- Tests/Public/Get-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerEventLog.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerGroup.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerId.Tests.ps1 | 6 +- ...-TeamViewerInstallationDirectory.Tests.ps1 | 4 +- .../Get-TeamViewerLogFilePath.Tests.ps1 | 8 +- .../Get-TeamViewerManagedDevice.Tests.ps1 | 4 +- .../Get-TeamViewerManagedGroup.Tests.ps1 | 4 +- .../Get-TeamViewerManagementId.Tests.ps1 | 13 +- Tests/Public/Get-TeamViewerManager.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerPolicy.Tests.ps1 | 4 +- ...eamViewerRoleAssignmentToAccount.Tests.ps1 | 4 +- ...mViewerRoleAssignmentToUserGroup.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerService.Tests.ps1 | 4 +- .../Public/Get-TeamViewerSsoDomain.Tests.ps1 | 4 +- .../Get-TeamViewerSsoExclusion.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerUser.Tests.ps1 | 4 +- .../Public/Get-TeamViewerUserGroup.Tests.ps1 | 16 +- .../Get-TeamViewerUserGroupMember.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerUserRole.Tests.ps1 | 4 +- Tests/Public/Get-TeamViewerVersion.Tests.ps1 | 10 +- Tests/Public/Invoke-TeamViewerPing.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerContact.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerGroup.Tests.ps1 | 4 +- .../New-TeamViewerManagedGroup.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerPolicy.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerUser.Tests.ps1 | 4 +- .../Public/New-TeamViewerUserGroup.Tests.ps1 | 4 +- Tests/Public/New-TeamViewerUserRole.tests.ps1 | 4 +- .../Public/Publish-TeamViewerGroup.Tests.ps1 | 4 +- .../Remove-TeamViewerAssignment.Tests.ps1 | 10 +- .../Public/Remove-TeamViewerContact.Tests.ps1 | 4 +- .../Remove-TeamViewerCustomization.Tests.ps1 | 8 +- .../Public/Remove-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/Remove-TeamViewerGroup.Tests.ps1 | 4 +- .../Remove-TeamViewerManagedDevice.Tests.ps1 | 4 +- ...eamViewerManagedDeviceManagement.Tests.ps1 | 4 +- .../Remove-TeamViewerManagedGroup.Tests.ps1 | 4 +- .../Public/Remove-TeamViewerManager.Tests.ps1 | 4 +- .../Public/Remove-TeamViewerPSProxy.Tests.ps1 | 4 +- .../Public/Remove-TeamViewerPolicy.Tests.ps1 | 4 +- ...eamViewerPolicyFromManagedDevice.Tests.ps1 | 6 +- ...Remove-TeamViewerRoleFromAccount.Tests.ps1 | 4 +- ...move-TeamViewerRoleFromUserGroup.Tests.ps1 | 4 +- .../Remove-TeamViewerSsoExclusion.Tests.ps1 | 4 +- Tests/Public/Remove-TeamViewerUser.Tests.ps1 | 4 +- .../Remove-TeamViewerUserGroup.Tests.ps1 | 4 +- ...Remove-TeamViewerUserGroupMember.Tests.ps1 | 4 +- .../Remove-TeamViewerUserRole.Tests.ps1 | 4 +- .../Restart-TeamViewerService.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerAccount.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerDevice.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerGroup.Tests.ps1 | 4 +- .../Set-TeamViewerManagedDevice.Tests.ps1 | 4 +- .../Set-TeamViewerManagedGroup.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerManager.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 | 6 +- Tests/Public/Set-TeamViewerPolicy.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerUser.Tests.ps1 | 4 +- .../Public/Set-TeamViewerUserGroup.Tests.ps1 | 4 +- Tests/Public/Set-TeamViewerUserRole.Tests.ps1 | 4 +- .../Public/Start-TeamViewerService.Tests.ps1 | 4 +- Tests/Public/Stop-TeamViewerService.Tests.ps1 | 4 +- .../Test-TeamViewerConnectivity.Tests.ps1 | 4 +- .../Test-TeamViewerInstallation.Tests.ps1 | 6 +- .../Unpublish-TeamViewerGroup.Tests.ps1 | 4 +- docs/TeamViewerPS.psm1 | 6 - 316 files changed, 6170 insertions(+), 380 deletions(-) delete mode 100644 .github/workflows/publish_testing.yml rename {docs/Cmdlets => Cmdlets}/Private/Add-Registry.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-DateTime.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-ErrorRecord.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerAccount.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerAuditEvent.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerConnectionReport.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerContact.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerGroupShare.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerManagedDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerManagedGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerManager.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerPolicy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerRestError.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerSsoDomain.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerUser.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerUserGroupMember.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/ConvertTo-TeamViewerUserRole.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-ClientId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-HostFile.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-InstalledSoftware.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-IpConfig.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-MSInfo32.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-NSLookUpData.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-OperatingSystem.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-RegistryPath.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-RouteTable.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TSCDirectoryFile.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TSCSearchDirectory.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TeamViewerApiUri.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TeamViewerLinuxGlobalConfig.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TeamViewerRegKeyPath.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TeamViewerServiceName.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Get-TypeAndValueOfRegistryValue.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Invoke-ExternalCommand.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Invoke-TeamViewerRestMethod.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-AssignmentErrorCode.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-CustomizationErrorCode.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerContactId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerDeviceId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerGroupId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerLanguage.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerManagedDeviceId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerManagedGroupId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerManagerId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerPolicyId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerSsoDomainId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerUserEmail.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerUserGroupId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerUserGroupMemberId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerUserId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Resolve-TeamViewerUserRoleId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Test-TcpConnection.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Private/Test-TeamViewer32on64.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerAssignment.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerCustomization.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerManagedDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerManager.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerRoleToAccount.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerRoleToUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerSsoExclusion.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Add-TeamViewerUserGroupMember.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Connect-TeamViewerApi.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Disconnect-TeamViewerApi.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Export-TeamViewerSystemInformation.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerAccount.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerConnectionReport.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerContact.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerCustomModuleId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerEventLog.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerInstallationDirectory.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerLogFilePath.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerManagedDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerManagedGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerManagementId.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerManager.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerPolicy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerService.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerSsoDomain.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerSsoExclusion.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerUser.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerUserGroupMember.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerUserRole.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Get-TeamViewerVersion.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Invoke-TeamViewerPackageDownload.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Invoke-TeamViewerPing.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerContact.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerManagedGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerPolicy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerUser.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/New-TeamViewerUserRole.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Publish-TeamViewerGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerAssignment.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerContact.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerCustomization.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerManagedDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerManagedDeviceManagement.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerManagedGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerManager.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerPSProxy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerPolicy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerRoleFromAccount.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerRoleFromUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerSsoExclusion.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerUser.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerUserGroupMember.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Remove-TeamViewerUserRole.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Restart-TeamViewerService.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerAPIUri.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerAccount.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerManagedDevice.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerManagedGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerManager.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerPSProxy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerPolicy.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerUser.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerUserGroup.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Set-TeamViewerUserRole.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Start-TeamViewerService.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Stop-TeamViewerService.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Test-TeamViewerConnectivity.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Test-TeamViewerInstallation.ps1 (100%) rename {docs/Cmdlets => Cmdlets}/Public/Unpublish-TeamViewerGroup.ps1 (100%) rename {docs => Cmdlets}/TeamViewerPS.Types.ps1 (100%) rename {docs => Cmdlets}/TeamViewerPS.format.ps1xml (100%) rename {docs => Cmdlets}/TeamViewerPS.psd1 (62%) create mode 100644 Cmdlets/TeamViewerPS.psm1 rename {docs => Cmdlets}/about_TeamViewerPS.md (100%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerAssignment.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerCustomization.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerManagedDevice.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerManager.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerRoleToAccount.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerRoleToUserGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerSsoExclusion.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Add-TeamViewerUserGroupMember.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Connect-TeamViewerApi.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Disconnect-TeamViewerApi.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Export-TeamViewerSystemInformation.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerAccount.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerConnectionReport.md (99%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerContact.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerCustomModuleId.md (92%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerDevice.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerEventLog.md (99%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerGroup.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerId.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerInstallationDirectory.md (91%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerLogFilePath.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerManagedDevice.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerManagedGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerManagementId.md (94%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerManager.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerPolicy.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerRoleAssignmentToAccount.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerRoleAssignmentToUserGroup.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerService.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerSsoDomain.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerSsoExclusion.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerUser.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerUserGroup.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerUserGroupMember.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerUserRole.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Get-TeamViewerVersion.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Invoke-TeamViewerPackageDownload.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Invoke-TeamViewerPing.md (96%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerContact.md (98%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerDevice.md (98%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerGroup.md (98%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerManagedGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerPolicy.md (98%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerUser.md (99%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerUserGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/New-TeamViewerUserRole.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Publish-TeamViewerGroup.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerAssignment.md (91%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerContact.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerCustomization.md (92%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerDevice.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerManagedDevice.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerManagedDeviceManagement.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerManagedGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerManager.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerPSProxy.md (92%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerPolicy.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerPolicyFromManagedDevice.md (100%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerRoleFromAccount.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerRoleFromUserGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerSsoExclusion.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerUser.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerUserGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerUserGroupMember.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Remove-TeamViewerUserRole.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Restart-TeamViewerService.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerAccount.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerDevice.md (99%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerGroup.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerManagedDevice.md (100%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerManagedGroup.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerManager.md (99%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerPSProxy.md (95%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerPolicy.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerUser.md (99%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerUserGroup.md (97%) rename {docs/Cmdlets_help => Docs/Help}/Set-TeamViewerUserRole.md (98%) rename {docs/Cmdlets_help => Docs/Help}/Start-TeamViewerService.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Stop-TeamViewerService.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Test-TeamViewerConnectivity.md (96%) rename {docs/Cmdlets_help => Docs/Help}/Test-TeamViewerInstallation.md (94%) rename {docs/Cmdlets_help => Docs/Help}/Unpublish-TeamViewerGroup.md (97%) delete mode 100644 docs/TeamViewerPS.psm1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dbd115..c0e079d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Stop' Install-Module -Name PSScriptAnalyzer -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 1.19.1 -Force -Verbose - Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -Settings (Join-Path -Path $env:GITHUB_WORKSPACE/Linters -ChildPath 'PSScriptAnalyzer.psd1') -ReportSummary -EnableExit + Invoke-ScriptAnalyzer -Path $env:GITHUB_WORKSPACE -Recurse -Settings (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Linters\PSScriptAnalyzer.psd1') -ReportSummary -EnableExit # Run tests - name: Run tests (via Pester) shell: pwsh @@ -46,4 +46,4 @@ jobs: $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Stop' Install-Module -Name platyPS, BuildHelpers -SkipPublisherCheck -Scope CurrentUser -Force - & $env:GITHUB_WORKSPACE/Build/New-Package.ps1 -Verbose + & (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Build\New-Package.ps1' -Verbose diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml deleted file mode 100644 index b943a5c..0000000 --- a/.github/workflows/publish_testing.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: PublishTesting - -on: - workflow_dispatch: - -jobs: - publish: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v3 - - - name: Build package - shell: pwsh - run: | - $ProgressPreference='SilentlyContinue' - Install-Module platyPS,BuildHelpers -Force -SkipPublisherCheck -Scope CurrentUser - & $env:GITHUB_WORKSPACE/Build/New-Package.ps1 -Verbose - - - name: Publish to poshtestgallery.com - env: - NUGET_APIKEY_TESTING: ${{ secrets.NUGET_APIKEY_TESTING }} - shell: pwsh - run: | - $ProgressPreference='SilentlyContinue' - Register-PSRepository ` - -Name PSTestGallery ` - -SourceLocation https://www.poshtestgallery.com/api/v2 - Publish-Module ` - -Path $env:GITHUB_WORKSPACE/Build/Output/ ` - -NuGetApiKey $env:NUGET_APIKEY_TESTING ` - -Repository PSTestGallery ` - -Force diff --git a/Build/New-Package.ps1 b/Build/New-Package.ps1 index da19d4f..10fe295 100644 --- a/Build/New-Package.ps1 +++ b/Build/New-Package.ps1 @@ -1,74 +1,54 @@ -#requires -Modules platyPS, BuildHelpers +#requires -Modules BuildHelpers, platyPS param( [Parameter()] - [string] - $BuildOutputPath = "$(Resolve-Path "$PSScriptRoot/..")/Build/Output" + [string]$Build_OutputPath = "$(Resolve-Path "$PSScriptRoot\..")\Build\Output" ) -$repoPath = Resolve-Path "$PSScriptRoot/.." +$Repo_RootPath = Resolve-Path -Path "$PSScriptRoot\.." +$Repo_CmdletPath = Resolve-Path -Path "$PSScriptRoot\..\Cmdlets" -if (Test-Path $BuildOutputPath) { - Write-Verbose 'Removing existing build output directory' - Remove-Item $BuildOutputPath -Recurse -ErrorAction SilentlyContinue +if (Test-Path -Path $Build_OutputPath) { + Write-Verbose 'Removing existing build output directory...' + Remove-Item -Path $Build_OutputPath -Recurse -ErrorAction SilentlyContinue } -Write-Verbose 'Creating build output directories.' -New-Item -Type Directory $BuildOutputPath | Out-Null +Write-Verbose 'Creating build output directories...' +New-Item -Type Directory $Build_OutputPath | Out-Null # Compile all functions into a single psm file -$targetFile = "$BuildOutputPath/TeamViewerPS.psm1" -Write-Verbose 'Compiling single-file TeamViewer module.' -$ModuleTypes = @(Get-ChildItem -Path "$repoPath/Docs/TeamViewerPS.Types.ps1") -$PrivateFunctions = @(Get-ChildItem ` - -Path "$repoPath/Docs/Cmdlets/Private/*.ps1" ` - -ErrorAction SilentlyContinue) +$Build_ModulePath = (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.psm1') + +Write-Verbose 'Compiling single-file TeamViewer module...' +$ModuleTypes = @(Get-ChildItem -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.Types.ps1')) + +$PrivateFunctions = @(Get-ChildItem -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'Private\*.ps1') -ErrorAction SilentlyContinue) Write-Verbose "Found $($PrivateFunctions.Count) private function files." -$PublicFunctions = @(Get-ChildItem ` - -Path "$repoPath/Docs/Cmdlets/Public/*.ps1" ` - -ErrorAction SilentlyContinue) + +$PublicFunctions = @(Get-ChildItem -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'Public\*.ps1') -ErrorAction SilentlyContinue) Write-Verbose "Found $($PublicFunctions.Count) public function files." -@($ModuleTypes + $PrivateFunctions + $PublicFunctions) | ` - Get-Content -Raw | ` - ForEach-Object { $_; "`r`n" } | ` - Set-Content -Path $targetFile -Encoding UTF8 + +@($ModuleTypes + $PrivateFunctions + $PublicFunctions) | Get-Content -Raw | ForEach-Object { $_; "`r`n" } | Set-Content -Path $Build_ModulePath -Encoding UTF8 # Create help from markdown -Write-Verbose 'Building help from Markdown' -New-ExternalHelp ` - -Path "$repoPath/Docs" ` - -OutputPath "$BuildOutputPath/en-US" | ` - Out-Null -New-ExternalHelp ` - -Path "$repoPath/Docs/Cmdlets_help" ` - -OutputPath "$BuildOutputPath/en-US" | ` - Out-Null +Write-Verbose 'Building help from Markdown...' +New-ExternalHelp -Path (Join-Path -Path $Repo_RootPath -ChildPath 'Docs') -OutputPath (Join-Path -Path $Build_OutputPath -ChildPath 'en-US') | Out-Null +New-ExternalHelp -Path (Join-Path -Path $Repo_RootPath -ChildPath 'Docs\Help') -OutputPath (Join-Path -Path $Build_OutputPath -ChildPath 'en-US') | Out-Null # Create module manifest -Write-Verbose 'Creating module manifest' -Copy-Item ` - -Path "$repoPath/Docs/TeamViewerPS.psd1" ` - -Destination "$BuildOutputPath/" -Copy-Item ` - -Path "$repoPath/Docs/*.format.ps1xml" ` - -Destination "$BuildOutputPath/" -Update-Metadata ` - -Path "$BuildOutputPath/TeamViewerPS.psd1" ` - -PropertyName 'FunctionsToExport' ` - -Value $PublicFunctions.BaseName +Write-Verbose 'Creating module manifest...' +Copy-Item -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.psd1') -Destination $Build_OutputPath +Copy-Item -Path (Join-Path -Path $Repo_CmdletPath -ChildPath '*.format.ps1xml') -Destination $Build_OutputPath + +Update-Metadata -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.psd1') -PropertyName 'FunctionsToExport' -Value $PublicFunctions.BaseName # Copy additional package files -Write-Verbose 'Copying additional files into the package' -Copy-Item ` - -Path ` - "$repoPath/LICENSE.md", ` - "$repoPath/CHANGELOG.md", ` - "$repoPath/README.md"` - -Destination "$BuildOutputPath/" +Write-Verbose 'Copying additional files into the package...' +Copy-Item -Path (Join-Path -Path $Repo_RootPath -ChildPath 'CHANGELOG.md') -Destination "$Build_OutputPath" +Copy-Item -Path (Join-Path -Path $Repo_RootPath -ChildPath 'LICENSE.md') -Destination "$Build_OutputPath" +Copy-Item -Path (Join-Path -Path $Repo_RootPath -ChildPath 'README.md') -Destination "$Build_OutputPath" Write-Verbose 'Listing package files:' -Push-Location $BuildOutputPath -Get-ChildItem -Recurse "$BuildOutputPath/" | ` - Sort-Object -Property FullName | ` - Resolve-Path -Relative +Push-Location -Path $Build_OutputPath +Get-ChildItem -Path "$Build_OutputPath\" -Recurse | Sort-Object -Property FullName | Resolve-Path -Relative Pop-Location diff --git a/docs/Cmdlets/Private/Add-Registry.ps1 b/Cmdlets/Private/Add-Registry.ps1 similarity index 100% rename from docs/Cmdlets/Private/Add-Registry.ps1 rename to Cmdlets/Private/Add-Registry.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-DateTime.ps1 b/Cmdlets/Private/ConvertTo-DateTime.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-DateTime.ps1 rename to Cmdlets/Private/ConvertTo-DateTime.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-ErrorRecord.ps1 b/Cmdlets/Private/ConvertTo-ErrorRecord.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-ErrorRecord.ps1 rename to Cmdlets/Private/ConvertTo-ErrorRecord.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerAccount.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerAccount.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerAccount.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerAccount.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerAuditEvent.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerAuditEvent.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerAuditEvent.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerAuditEvent.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerConnectionReport.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerConnectionReport.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerConnectionReport.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerConnectionReport.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerContact.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerContact.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerContact.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerContact.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerDevice.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerDevice.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerDevice.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerDevice.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerGroupShare.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerGroupShare.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerGroupShare.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerGroupShare.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerManagedDevice.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerManagedDevice.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerManagedDevice.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerManagedDevice.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerManagedGroup.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerManagedGroup.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerManagedGroup.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerManagedGroup.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerManager.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerManager.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerManager.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerPolicy.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerPolicy.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerPolicy.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerPolicy.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerRestError.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerRestError.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerRestError.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerRestError.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUser.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerRoleAssignedUserGroup.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerSsoDomain.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerSsoDomain.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerSsoDomain.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerSsoDomain.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerUserGroup.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerUserGroupMember.ps1 diff --git a/docs/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 similarity index 100% rename from docs/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/Cmdlets/Private/Get-ClientId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-ClientId.ps1 rename to Cmdlets/Private/Get-ClientId.ps1 diff --git a/docs/Cmdlets/Private/Get-HostFile.ps1 b/Cmdlets/Private/Get-HostFile.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-HostFile.ps1 rename to Cmdlets/Private/Get-HostFile.ps1 diff --git a/docs/Cmdlets/Private/Get-InstalledSoftware.ps1 b/Cmdlets/Private/Get-InstalledSoftware.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-InstalledSoftware.ps1 rename to Cmdlets/Private/Get-InstalledSoftware.ps1 diff --git a/docs/Cmdlets/Private/Get-IpConfig.ps1 b/Cmdlets/Private/Get-IpConfig.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-IpConfig.ps1 rename to Cmdlets/Private/Get-IpConfig.ps1 diff --git a/docs/Cmdlets/Private/Get-MSInfo32.ps1 b/Cmdlets/Private/Get-MSInfo32.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-MSInfo32.ps1 rename to Cmdlets/Private/Get-MSInfo32.ps1 diff --git a/docs/Cmdlets/Private/Get-NSLookUpData.ps1 b/Cmdlets/Private/Get-NSLookUpData.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-NSLookUpData.ps1 rename to Cmdlets/Private/Get-NSLookUpData.ps1 diff --git a/docs/Cmdlets/Private/Get-OperatingSystem.ps1 b/Cmdlets/Private/Get-OperatingSystem.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-OperatingSystem.ps1 rename to Cmdlets/Private/Get-OperatingSystem.ps1 diff --git a/docs/Cmdlets/Private/Get-RegistryPath.ps1 b/Cmdlets/Private/Get-RegistryPath.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-RegistryPath.ps1 rename to Cmdlets/Private/Get-RegistryPath.ps1 diff --git a/docs/Cmdlets/Private/Get-RouteTable.ps1 b/Cmdlets/Private/Get-RouteTable.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-RouteTable.ps1 rename to Cmdlets/Private/Get-RouteTable.ps1 diff --git a/docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 b/Cmdlets/Private/Get-TSCDirectoryFile.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TSCDirectoryFile.ps1 rename to Cmdlets/Private/Get-TSCDirectoryFile.ps1 diff --git a/docs/Cmdlets/Private/Get-TSCSearchDirectory.ps1 b/Cmdlets/Private/Get-TSCSearchDirectory.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TSCSearchDirectory.ps1 rename to Cmdlets/Private/Get-TSCSearchDirectory.ps1 diff --git a/docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 b/Cmdlets/Private/Get-TeamViewerApiUri.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TeamViewerApiUri.ps1 rename to Cmdlets/Private/Get-TeamViewerApiUri.ps1 diff --git a/docs/Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 b/Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 rename to Cmdlets/Private/Get-TeamViewerLinuxGlobalConfig.ps1 diff --git a/docs/Cmdlets/Private/Get-TeamViewerRegKeyPath.ps1 b/Cmdlets/Private/Get-TeamViewerRegKeyPath.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TeamViewerRegKeyPath.ps1 rename to Cmdlets/Private/Get-TeamViewerRegKeyPath.ps1 diff --git a/docs/Cmdlets/Private/Get-TeamViewerServiceName.ps1 b/Cmdlets/Private/Get-TeamViewerServiceName.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TeamViewerServiceName.ps1 rename to Cmdlets/Private/Get-TeamViewerServiceName.ps1 diff --git a/docs/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 b/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 similarity index 100% rename from docs/Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 rename to Cmdlets/Private/Get-TypeAndValueOfRegistryValue.ps1 diff --git a/docs/Cmdlets/Private/Invoke-ExternalCommand.ps1 b/Cmdlets/Private/Invoke-ExternalCommand.ps1 similarity index 100% rename from docs/Cmdlets/Private/Invoke-ExternalCommand.ps1 rename to Cmdlets/Private/Invoke-ExternalCommand.ps1 diff --git a/docs/Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 b/Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 similarity index 100% rename from docs/Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 rename to Cmdlets/Private/Invoke-TeamViewerRestMethod.ps1 diff --git a/docs/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 b/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 rename to Cmdlets/Private/Resolve-AssignmentErrorCode.ps1 diff --git a/docs/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 b/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 rename to Cmdlets/Private/Resolve-CustomizationErrorCode.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerContactId.ps1 b/Cmdlets/Private/Resolve-TeamViewerContactId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerContactId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerContactId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerDeviceId.ps1 b/Cmdlets/Private/Resolve-TeamViewerDeviceId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerDeviceId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerDeviceId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerGroupId.ps1 b/Cmdlets/Private/Resolve-TeamViewerGroupId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerGroupId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerGroupId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerLanguage.ps1 b/Cmdlets/Private/Resolve-TeamViewerLanguage.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerLanguage.ps1 rename to Cmdlets/Private/Resolve-TeamViewerLanguage.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerManagedDeviceId.ps1 b/Cmdlets/Private/Resolve-TeamViewerManagedDeviceId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerManagedDeviceId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerManagedDeviceId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerManagedGroupId.ps1 b/Cmdlets/Private/Resolve-TeamViewerManagedGroupId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerManagedGroupId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerManagedGroupId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerManagerId.ps1 b/Cmdlets/Private/Resolve-TeamViewerManagerId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerManagerId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerManagerId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerPolicyId.ps1 b/Cmdlets/Private/Resolve-TeamViewerPolicyId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerPolicyId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerPolicyId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerSsoDomainId.ps1 b/Cmdlets/Private/Resolve-TeamViewerSsoDomainId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerSsoDomainId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerSsoDomainId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerUserEmail.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserEmail.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerUserEmail.ps1 rename to Cmdlets/Private/Resolve-TeamViewerUserEmail.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerUserGroupId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerUserGroupMemberId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerUserId.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerUserId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerUserId.ps1 diff --git a/docs/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 similarity index 100% rename from docs/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 rename to Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 diff --git a/docs/Cmdlets/Private/Test-TcpConnection.ps1 b/Cmdlets/Private/Test-TcpConnection.ps1 similarity index 100% rename from docs/Cmdlets/Private/Test-TcpConnection.ps1 rename to Cmdlets/Private/Test-TcpConnection.ps1 diff --git a/docs/Cmdlets/Private/Test-TeamViewer32on64.ps1 b/Cmdlets/Private/Test-TeamViewer32on64.ps1 similarity index 100% rename from docs/Cmdlets/Private/Test-TeamViewer32on64.ps1 rename to Cmdlets/Private/Test-TeamViewer32on64.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1 b/Cmdlets/Public/Add-TeamViewerAssignment.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1 rename to Cmdlets/Public/Add-TeamViewerAssignment.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1 b/Cmdlets/Public/Add-TeamViewerCustomization.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1 rename to Cmdlets/Public/Add-TeamViewerCustomization.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1 b/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1 rename to Cmdlets/Public/Add-TeamViewerManagedDevice.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerManager.ps1 b/Cmdlets/Public/Add-TeamViewerManager.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerManager.ps1 rename to Cmdlets/Public/Add-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 b/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 rename to Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 rename to Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1 b/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1 rename to Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1 diff --git a/docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 similarity index 100% rename from docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 rename to Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1 diff --git a/docs/Cmdlets/Public/Connect-TeamViewerApi.ps1 b/Cmdlets/Public/Connect-TeamViewerApi.ps1 similarity index 100% rename from docs/Cmdlets/Public/Connect-TeamViewerApi.ps1 rename to Cmdlets/Public/Connect-TeamViewerApi.ps1 diff --git a/docs/Cmdlets/Public/Disconnect-TeamViewerApi.ps1 b/Cmdlets/Public/Disconnect-TeamViewerApi.ps1 similarity index 100% rename from docs/Cmdlets/Public/Disconnect-TeamViewerApi.ps1 rename to Cmdlets/Public/Disconnect-TeamViewerApi.ps1 diff --git a/docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 b/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 similarity index 100% rename from docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 rename to Cmdlets/Public/Export-TeamViewerSystemInformation.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerAccount.ps1 b/Cmdlets/Public/Get-TeamViewerAccount.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerAccount.ps1 rename to Cmdlets/Public/Get-TeamViewerAccount.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1 b/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1 rename to Cmdlets/Public/Get-TeamViewerConnectionReport.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerContact.ps1 b/Cmdlets/Public/Get-TeamViewerContact.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerContact.ps1 rename to Cmdlets/Public/Get-TeamViewerContact.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 b/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 rename to Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerDevice.ps1 b/Cmdlets/Public/Get-TeamViewerDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerDevice.ps1 rename to Cmdlets/Public/Get-TeamViewerDevice.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerEventLog.ps1 b/Cmdlets/Public/Get-TeamViewerEventLog.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerEventLog.ps1 rename to Cmdlets/Public/Get-TeamViewerEventLog.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerGroup.ps1 b/Cmdlets/Public/Get-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerGroup.ps1 rename to Cmdlets/Public/Get-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerId.ps1 b/Cmdlets/Public/Get-TeamViewerId.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerId.ps1 rename to Cmdlets/Public/Get-TeamViewerId.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 b/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 rename to Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 b/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 rename to Cmdlets/Public/Get-TeamViewerLogFilePath.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1 b/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1 rename to Cmdlets/Public/Get-TeamViewerManagedDevice.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1 b/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1 rename to Cmdlets/Public/Get-TeamViewerManagedGroup.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerManagementId.ps1 b/Cmdlets/Public/Get-TeamViewerManagementId.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerManagementId.ps1 rename to Cmdlets/Public/Get-TeamViewerManagementId.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerManager.ps1 b/Cmdlets/Public/Get-TeamViewerManager.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerManager.ps1 rename to Cmdlets/Public/Get-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerPolicy.ps1 b/Cmdlets/Public/Get-TeamViewerPolicy.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerPolicy.ps1 rename to Cmdlets/Public/Get-TeamViewerPolicy.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 b/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 rename to Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 b/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 rename to Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerService.ps1 b/Cmdlets/Public/Get-TeamViewerService.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerService.ps1 rename to Cmdlets/Public/Get-TeamViewerService.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1 b/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1 rename to Cmdlets/Public/Get-TeamViewerSsoDomain.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1 b/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1 rename to Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerUser.ps1 b/Cmdlets/Public/Get-TeamViewerUser.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerUser.ps1 rename to Cmdlets/Public/Get-TeamViewerUser.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1 b/Cmdlets/Public/Get-TeamViewerUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1 rename to Cmdlets/Public/Get-TeamViewerUserGroup.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 b/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 rename to Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1 b/Cmdlets/Public/Get-TeamViewerUserRole.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1 rename to Cmdlets/Public/Get-TeamViewerUserRole.ps1 diff --git a/docs/Cmdlets/Public/Get-TeamViewerVersion.ps1 b/Cmdlets/Public/Get-TeamViewerVersion.ps1 similarity index 100% rename from docs/Cmdlets/Public/Get-TeamViewerVersion.ps1 rename to Cmdlets/Public/Get-TeamViewerVersion.ps1 diff --git a/docs/Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 b/Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 similarity index 100% rename from docs/Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 rename to Cmdlets/Public/Invoke-TeamViewerPackageDownload.ps1 diff --git a/docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1 b/Cmdlets/Public/Invoke-TeamViewerPing.ps1 similarity index 100% rename from docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1 rename to Cmdlets/Public/Invoke-TeamViewerPing.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerContact.ps1 b/Cmdlets/Public/New-TeamViewerContact.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerContact.ps1 rename to Cmdlets/Public/New-TeamViewerContact.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerDevice.ps1 b/Cmdlets/Public/New-TeamViewerDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerDevice.ps1 rename to Cmdlets/Public/New-TeamViewerDevice.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerGroup.ps1 b/Cmdlets/Public/New-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerGroup.ps1 rename to Cmdlets/Public/New-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerManagedGroup.ps1 b/Cmdlets/Public/New-TeamViewerManagedGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerManagedGroup.ps1 rename to Cmdlets/Public/New-TeamViewerManagedGroup.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerPolicy.ps1 b/Cmdlets/Public/New-TeamViewerPolicy.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerPolicy.ps1 rename to Cmdlets/Public/New-TeamViewerPolicy.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerUser.ps1 b/Cmdlets/Public/New-TeamViewerUser.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerUser.ps1 rename to Cmdlets/Public/New-TeamViewerUser.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1 b/Cmdlets/Public/New-TeamViewerUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1 rename to Cmdlets/Public/New-TeamViewerUserGroup.ps1 diff --git a/docs/Cmdlets/Public/New-TeamViewerUserRole.ps1 b/Cmdlets/Public/New-TeamViewerUserRole.ps1 similarity index 100% rename from docs/Cmdlets/Public/New-TeamViewerUserRole.ps1 rename to Cmdlets/Public/New-TeamViewerUserRole.ps1 diff --git a/docs/Cmdlets/Public/Publish-TeamViewerGroup.ps1 b/Cmdlets/Public/Publish-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Publish-TeamViewerGroup.ps1 rename to Cmdlets/Public/Publish-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 b/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 rename to Cmdlets/Public/Remove-TeamViewerAssignment.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerContact.ps1 b/Cmdlets/Public/Remove-TeamViewerContact.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerContact.ps1 rename to Cmdlets/Public/Remove-TeamViewerContact.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 b/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 rename to Cmdlets/Public/Remove-TeamViewerCustomization.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerDevice.ps1 b/Cmdlets/Public/Remove-TeamViewerDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerDevice.ps1 rename to Cmdlets/Public/Remove-TeamViewerDevice.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerGroup.ps1 b/Cmdlets/Public/Remove-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerGroup.ps1 rename to Cmdlets/Public/Remove-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1 b/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1 rename to Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1 b/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1 rename to Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1 b/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1 rename to Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerManager.ps1 b/Cmdlets/Public/Remove-TeamViewerManager.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerManager.ps1 rename to Cmdlets/Public/Remove-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 rename to Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPolicy.ps1 b/Cmdlets/Public/Remove-TeamViewerPolicy.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerPolicy.ps1 rename to Cmdlets/Public/Remove-TeamViewerPolicy.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 b/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 rename to Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 b/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 rename to Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 b/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 rename to Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1 b/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1 rename to Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerUser.ps1 b/Cmdlets/Public/Remove-TeamViewerUser.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerUser.ps1 rename to Cmdlets/Public/Remove-TeamViewerUser.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 b/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserGroup.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 b/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1 diff --git a/docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 similarity index 100% rename from docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserRole.ps1 diff --git a/docs/Cmdlets/Public/Restart-TeamViewerService.ps1 b/Cmdlets/Public/Restart-TeamViewerService.ps1 similarity index 100% rename from docs/Cmdlets/Public/Restart-TeamViewerService.ps1 rename to Cmdlets/Public/Restart-TeamViewerService.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 b/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerAPIUri.ps1 rename to Cmdlets/Public/Set-TeamViewerAPIUri.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerAccount.ps1 b/Cmdlets/Public/Set-TeamViewerAccount.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerAccount.ps1 rename to Cmdlets/Public/Set-TeamViewerAccount.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerDevice.ps1 b/Cmdlets/Public/Set-TeamViewerDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerDevice.ps1 rename to Cmdlets/Public/Set-TeamViewerDevice.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerGroup.ps1 b/Cmdlets/Public/Set-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerGroup.ps1 rename to Cmdlets/Public/Set-TeamViewerGroup.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 b/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 rename to Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 b/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 rename to Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerManager.ps1 b/Cmdlets/Public/Set-TeamViewerManager.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerManager.ps1 rename to Cmdlets/Public/Set-TeamViewerManager.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 b/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1 rename to Cmdlets/Public/Set-TeamViewerPSProxy.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerPolicy.ps1 b/Cmdlets/Public/Set-TeamViewerPolicy.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerPolicy.ps1 rename to Cmdlets/Public/Set-TeamViewerPolicy.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUser.ps1 b/Cmdlets/Public/Set-TeamViewerUser.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerUser.ps1 rename to Cmdlets/Public/Set-TeamViewerUser.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1 b/Cmdlets/Public/Set-TeamViewerUserGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1 rename to Cmdlets/Public/Set-TeamViewerUserGroup.ps1 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/Cmdlets/Public/Set-TeamViewerUserRole.ps1 similarity index 100% rename from docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 rename to Cmdlets/Public/Set-TeamViewerUserRole.ps1 diff --git a/docs/Cmdlets/Public/Start-TeamViewerService.ps1 b/Cmdlets/Public/Start-TeamViewerService.ps1 similarity index 100% rename from docs/Cmdlets/Public/Start-TeamViewerService.ps1 rename to Cmdlets/Public/Start-TeamViewerService.ps1 diff --git a/docs/Cmdlets/Public/Stop-TeamViewerService.ps1 b/Cmdlets/Public/Stop-TeamViewerService.ps1 similarity index 100% rename from docs/Cmdlets/Public/Stop-TeamViewerService.ps1 rename to Cmdlets/Public/Stop-TeamViewerService.ps1 diff --git a/docs/Cmdlets/Public/Test-TeamViewerConnectivity.ps1 b/Cmdlets/Public/Test-TeamViewerConnectivity.ps1 similarity index 100% rename from docs/Cmdlets/Public/Test-TeamViewerConnectivity.ps1 rename to Cmdlets/Public/Test-TeamViewerConnectivity.ps1 diff --git a/docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1 b/Cmdlets/Public/Test-TeamViewerInstallation.ps1 similarity index 100% rename from docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1 rename to Cmdlets/Public/Test-TeamViewerInstallation.ps1 diff --git a/docs/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1 b/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1 similarity index 100% rename from docs/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1 rename to Cmdlets/Public/Unpublish-TeamViewerGroup.ps1 diff --git a/docs/TeamViewerPS.Types.ps1 b/Cmdlets/TeamViewerPS.Types.ps1 similarity index 100% rename from docs/TeamViewerPS.Types.ps1 rename to Cmdlets/TeamViewerPS.Types.ps1 diff --git a/docs/TeamViewerPS.format.ps1xml b/Cmdlets/TeamViewerPS.format.ps1xml similarity index 100% rename from docs/TeamViewerPS.format.ps1xml rename to Cmdlets/TeamViewerPS.format.ps1xml diff --git a/docs/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 similarity index 62% rename from docs/TeamViewerPS.psd1 rename to Cmdlets/TeamViewerPS.psd1 index 0ffbf58..04bbd70 100644 --- a/docs/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -1,4 +1,4 @@ -@{ +@{ # Script module or binary module file associated with this manifest. RootModule = 'TeamViewerPS.psm1' @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = '*' + FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Cmdlets/TeamViewerPS.psm1 b/Cmdlets/TeamViewerPS.psm1 new file mode 100644 index 0000000..8f8353d --- /dev/null +++ b/Cmdlets/TeamViewerPS.psm1 @@ -0,0 +1,5849 @@ +enum TeamViewerConnectionReportSessionType { + RemoteConnection = 1 + RemoteSupportActive = 2 + RemoteSupportActiveSdk = 3 +} + +enum PolicyType { + TeamViewer = 1 + Monitoring = 4 + PatchManagement = 5 +} + + + +function Add-Registry { + param ( + [Microsoft.Win32.RegistryKey]$RegKey, + [string]$Program + ) + + #CustomObject including all information for each registry and sub keys + $retRegKey = [PSCustomObject]@{ + Program = $Program + RegistryPath = $RegKey.Name + Entries = @() + } + Write-Output "Collecting registry data $($retRegKey.RegistryPath)" + foreach ($valueName in $RegKey.GetValueNames()) { + $value = $RegKey.GetValue($valueName) + $type, $value = Get-TypeAndValueOfRegistryValue -RegKey $RegKey -ValueName $valueName + $blackList = @('BuddyLoginTokenAES', 'BuddyLoginTokenSecretAES', 'Certificate', 'CertificateKey', 'CertificateKeyProtected', + 'MultiPwdMgmtPwdData', 'PermanentPassword', 'PK', 'SecurityPasswordAES', 'SK', 'SRPPasswordMachineIdentifier') + foreach ($blackListValue in $blackList) { + if ($valueName -eq $blackListValue) { + $value = '___PRIVATE___' + } + } + $entry = [PSCustomObject]@{ + Name = $valueName + Value = $value + Type = $type + } + $retRegKey.Entries += $entry + } + + foreach ($subKeyName in $RegKey.GetSubKeyNames()) { + $subKey = $RegKey.OpenSubKey($subKeyName) + Add-Registry -RegKey $subKey -Program $subKeyName + } + #Adding CustomObject to array declared in Get-RegistryPaths + $AllTVRegistryData.Add($retRegKey) | Out-Null +} + + + + + +function ConvertTo-DateTime { + param( + [Parameter(ValueFromPipeline)] + [string] + $InputString + ) + + process { + try { + Write-Output ([DateTime]::Parse($InputString)) + } + catch { + Write-Output $null + } + } +} + + +function ConvertTo-ErrorRecord { + param( + [Parameter(ValueFromPipeline)] + [object] + $InputObject, + + [Parameter()] + [System.Management.Automation.ErrorCategory] + $ErrorCategory = [System.Management.Automation.ErrorCategory]::NotSpecified + ) + Process { + $category = $ErrorCategory + $message = $InputObject.ToString() + $errorId = 'TeamViewerError' + + if ($InputObject.PSObject.TypeNames -contains 'TeamViewerPS.RestError') { + $category = switch ($InputObject.ErrorCategory) { + 'invalid_request' { [System.Management.Automation.ErrorCategory]::InvalidArgument } + 'invalid_token' { [System.Management.Automation.ErrorCategory]::AuthenticationError } + 'internal_error' { [System.Management.Automation.ErrorCategory]::NotSpecified } + 'rate_limit_reached' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } + 'token_expired' { [System.Management.Automation.ErrorCategory]::AuthenticationError } + 'wrong_credentials' { [System.Management.Automation.ErrorCategory]::AuthenticationError } + 'invalid_client' { [System.Management.Automation.ErrorCategory]::InvalidArgument } + 'not_found' { [System.Management.Automation.ErrorCategory]::ObjectNotFound } + 'too_many_retries' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } + 'invalid_permission' { [System.Management.Automation.ErrorCategory]::PermissionDenied } + default { [System.Management.Automation.ErrorCategory]::NotSpecified } + } + $errorId = 'TeamViewerRestError' + } + + $exception = [System.Management.Automation.RuntimeException]($message) + $errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $category, $null + $errorRecord.ErrorDetails = $message + return $errorRecord + } +} + + + +function ConvertTo-TeamViewerAccount { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Name = $InputObject.name + Email = $InputObject.email + UserId = $InputObject.userid + CompanyName = $InputObject.company_name + IsEmailValidated = $InputObject.email_validated + EmailLanguage = $InputObject.email_language + } + if ($InputObject.email_language -And $InputObject.email_language -Ne 'auto') { + $properties["EmailLanguage"] = [System.Globalization.CultureInfo]($InputObject.email_language) + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Account') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name) <$($this.Email)>" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerAuditEvent { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Name = $InputObject.EventName + Type = $InputObject.EventType + Timestamp = $InputObject.Timestamp | ConvertTo-DateTime + Author = $InputObject.Author + AffectedItem = $InputObject.AffectedItem + EventDetails = $InputObject.EventDetails + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.AuditEvent') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "[$($this.Timestamp)] $($this.Name) ($($this.Type))" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerConnectionReport { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.id + UserId = $InputObject.userid + UserName = $InputObject.username + DeviceId = $InputObject.deviceid + DeviceName = $InputObject.devicename + GroupId = $InputObject.groupid + GroupName = $InputObject.groupname + SupportSessionType = [TeamViewerConnectionReportSessionType]$InputObject.support_session_type + StartDate = $InputObject.start_date | ConvertTo-DateTime + EndDate = $InputObject.end_date | ConvertTo-DateTime + SessionCode = $InputObject.session_code + Fee = $InputObject.fee + BillingState = $InputObject.billing_state + Currency = $InputObject.currency + Notes = $InputObject.notes + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ConnectionReport') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerContact { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.contact_id + UserId = $InputObject.user_id + GroupId = $InputObject.groupid + Name = $InputObject.name + Description = $InputObject.description + OnlineState = $InputObject.online_state + ProfilePictureUrl = $InputObject.profilepicture_url + SupportedFeatures = $InputObject.supported_features + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Contact') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerDevice { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $remoteControlId = $InputObject.remotecontrol_id | ` + Select-String -Pattern 'r(\d+)' | ` + ForEach-Object { $_.Matches.Groups[1].Value } + $properties = @{ + Id = $InputObject.device_id + TeamViewerId = $remoteControlId + GroupId = $InputObject.groupid + Name = $InputObject.alias + Description = $InputObject.description + OnlineState = $InputObject.online_state + IsAssignedToCurrentAccount = $InputObject.assigned_to + SupportedFeatures = $InputObject.supported_features + } + if ($InputObject.policy_id) { + $properties['PolicyId'] = $InputObject.policy_id + } + if ($InputObject.last_seen) { + $properties['LastSeenAt'] = [datetime]($InputObject.last_seen) + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Device') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.id + Name = $InputObject.name + Permissions = $InputObject.permissions + SharedWith = @($InputObject.shared_with | ConvertTo-TeamViewerGroupShare) + } + if ($InputObject.owner) { + $properties.Owner = [pscustomobject]@{ + UserId = $InputObject.owner.userid + Name = $InputObject.owner.name + } + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Group') + Write-Output $result + } +} + + +function ConvertTo-TeamViewerGroupShare { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + UserId = $InputObject.userid + Name = $InputObject.name + Permissions = $InputObject.permissions + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.GroupShare') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.UserId)" + } + Write-Output $result + } +} + + +function ConvertTo-TeamViewerManagedDevice { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [guid]$InputObject.id + Name = $InputObject.name + TeamViewerId = $InputObject.TeamViewerId + IsOnline = $InputObject.isOnline + } + + if ($InputObject.last_seen) { + $properties['LastSeenAt'] = Get-Date -Date $InputObject.last_seen + } + + if ($InputObject.teamviewerPolicyId) { + $properties["PolicyId"] = [guid]$InputObject.teamviewerPolicyId + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedDevice') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerManagedGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [guid]$InputObject.id + Name = $InputObject.name + } + if ($InputObject.policy_id) { + $properties["PolicyId"] = $InputObject.policy_id + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedGroup') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerManager { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject, + + [Parameter(Mandatory = $true, ParameterSetName = "GroupManager")] + [guid] + $GroupId, + + [Parameter(Mandatory = $true, ParameterSetName = "DeviceManager")] + [guid] + $DeviceId + ) + process { + $properties = @{ + Id = [guid]$InputObject.id + ManagerType = $InputObject.type + Name = $InputObject.name + Permissions = $InputObject.permissions + } + + switch ($InputObject.type) { + 'account' { + $properties.AccountId = $InputObject.accountId + } + 'company' { + $properties.CompanyId = $InputObject.companyId + } + } + + switch ($PsCmdlet.ParameterSetName) { + 'GroupManager' { + $properties.GroupId = $GroupId + } + 'DeviceManager' { + $properties.DeviceId = $DeviceId + } + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Manager') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerPolicy { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + + process { + $properties = @{ + Id = $InputObject.policy_id + Name = $InputObject.name + Settings = @( + $InputObject.settings | ForEach-Object { + @{ + Key = $_.key + Value = $_.value + Enforce = $_.enforce + } + } + ) + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Policy') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerRestError { + param( + [parameter(ValueFromPipeline)] + $InputError + ) + Process { + try { + $errorObject = ($InputError | Out-String | ConvertFrom-Json) + $result = [PSCustomObject]@{ + Message = $errorObject.error_description + ErrorCategory = $errorObject.error + ErrorCode = $errorObject.error_code + ErrorSignature = $errorObject.error_signature + } + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "$($this.Message) ($($this.ErrorCategory))" + } + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RestError') + return $result + } + catch { + return $InputError + } + } +} + + + +function ConvertTo-TeamViewerRoleAssignedUser { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{AssignedUsers = ($InputObject.trim('u'))} + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUser') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerRoleAssignedUserGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{AssignedGroups = ($InputObject)} + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUserGroup') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerSsoDomain { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.DomainId + Name = $InputObject.DomainName + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.SsoDomain') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUser { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject, + + [Parameter()] + [ValidateSet('All', 'Minimal')] + $PropertiesToLoad = 'All' + ) + process { + $properties = @{ + Id = $InputObject.id + Name = $InputObject.name + Email = $InputObject.email + } + if ($PropertiesToLoad -Eq 'All') { + $properties += @{ + Permissions = $InputObject.permissions -split ',' + Active = $InputObject.active + LastAccessDate = $InputObject.last_access_date | ConvertTo-DateTime + } + if ($InputObject.activated_license_id) { + $properties += @{ + ActivatedLicenseId = [guid]$InputObject.activated_license_id + ActivatedLicenseName = $InputObject.activated_license_name + ActivatedSubLicenseName = $InputObject.activated_subLicense_name + } + } + if ($InputObject.activated_meeting_license_key) { + $properties += @{ + ActivatedMeetingLicenseId = [guid]$InputObject.activated_meeting_license_key + } + } + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.User') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name) <$($this.Email)>" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUserGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [UInt64]$InputObject.id + Name = $InputObject.name + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroup') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUserGroupMember { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + AccountId = [int]$InputObject.accountId + Name = $InputObject.name + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroupMember') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUserRole { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + RoleName = $InputObject.Name + RoleID = $InputObject.Id + } + if ($InputObject.Permissions) { + foreach ($permission in $InputObject.Permissions.PSObject.Properties) { + $properties[$permission.Name] = $permission.Value + } + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserRole') + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "[$($this.RoleName)] [$($this.RoleID)] $($this.Permissions))" + } + Write-Output $result + } +} + + + + +function Get-ClientId { + if (Test-Path -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer') { + $mainKey = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' + $id = [int]$mainKey.ClientID + } + elseif (Test-Path -Path 'HKLM:\Software\TeamViewer') { + $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' + $id = [int]$mainKey.ClientID + } + return $id +} + + + +function Get-HostFile { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + process { + $regPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' + $regKey = Get-ItemProperty -Path $regPath + $hostsPath = Join-Path -Path $regKey.DataBasePath -ChildPath 'hosts' + $hostsFile = Get-Content -Path $hostsPath + $hostsFile | Out-File -FilePath "$OutputPath\Data\hosts.txt" + Write-Output "hosts file collected and saved to $OutputPath\Data\hosts.txt" + } +} + + + +function Get-InstalledSoftware { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $regUninstall = @{ + InstalledSoftware32 = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' + InstalledSoftware64 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' + } + } + Process { + foreach ($Name in $regUninstall.keys) { + $regKeys = $regUninstall[$Name] + $regKey = Get-ItemProperty -Path "$regKeys\*" + if ($null -ne $regKey) { + $subKeys = $regKey.PSChildName + if ($null -ne $subKeys) { + $installedPrograms = @() + foreach ($subKey in $subKeys) { + $tmpSubkey = Get-ItemProperty -Path "$regKeys\$subKey" + $programmName = $tmpSubkey.DisplayName + $displayVersion = $tmpSubkey.DisplayVersion + if ($null -ne $programmName) { + $tmpSoftwareData = "$programmName | $displayVersion" + $installedPrograms += $tmpSoftwareData + } + } + } + $installedPrograms | Sort-Object | Out-File -FilePath "$OutputPath\Data\$Name.txt" + Write-Output "$Name collected and saved to $OutputPath\Data\$Name.txt" + } + } + } +} + + + + + +function Get-IpConfig { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Process { + try { + ipconfig /all | Out-File -FilePath "$OutputPath\Data\ipconfig.txt" -Encoding utf8 + Write-Output "ipconfig data collected and saved to $OutputPath\Data\ipconfig.txt" + } + catch { + Write-Error "An error occurred while collecting ipconfig data: $_" + } + } +} + + + +function Get-MSInfo32 { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Process { + try { + Start-Process -FilePath msinfo32.exe -ArgumentList "/nfo $OutputPath\Data\msinfo32.nfo" -Wait + + Write-Output "msinfo data collected and saved to $OutputPath\Data\msinfo32.nfo" + } + catch { + Write-Error "An error occurred while collecting msinfo data: $_" + } + } +} + + + +function Get-NSLookUpData { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $Ipv4DnsServer = @($null, 'tv-ns1.teamviewer.com', 'tv-ns2.teamviewer.com', 'tv-ns3.teamviewer.com', + 'tv-ns4.teamviewer.com', 'tv-ns5.teamviewer.com', '8.8.8.8', '1.1.1.1') + $Ipv4DnsName = @( 'master1.teamviewer.com', 'router1.teamviewer.com', 'google.com', + 'login.teamviewer.com', 'www.teamviewer.com') + $output = $null + } + Process { + try { + foreach ($DnsName in $Ipv4DnsName ) { + foreach ($DnsServer in $Ipv4DnsServer) { + Write-Output "Collecting nslookup.exe information from $DnsName $DnsServer. This might take a while" + $output += "nslookup information for: $DnsName $DnsServer `r`n" + $arguments = "-debug ""$DnsName""" + if ($DnsServer) { + $arguments += " ""$DnsServer""" + } + $processInfo = New-Object System.Diagnostics.ProcessStartInfo + $processInfo.FileName = 'nslookup.exe' + $processInfo.Arguments = $arguments + $processInfo.WindowStyle = 'Hidden' + $processInfo.UseShellExecute = $false + $processInfo.RedirectStandardOutput = $true + + $process = [System.Diagnostics.Process]::Start($processInfo) + $output += $process.StandardOutput.ReadToEnd() + $process.WaitForExit(60000) + if (-not $process.HasExited) { + $process.Kill() + continue + } + $output += $process.StandardOutput.ReadToEnd() + } + } + $output | Out-File "$OutputPath\Data\nslookup.txt" + } + + catch { + Write-Error "Error collecting nslookup information: $_" + } + } +} + + + + + +function Get-OperatingSystem { + if ($IsLinux) { + return 'Linux' + } + if ($IsMacOS) { + return 'MacOS' + } + if ($IsWindows -Or $env:OS -match '^Windows') { + return 'Windows' + } +} + + + +function Get-RegistryPath { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $SearchProgramms = @('TeamViewer', 'Blizz', 'TeamViewerMeeting') + $RegistrySearchPathsLocalMachine = @('SOFTWARE\Wow6432Node', 'SOFTWARE') + $RegistrySearchPathsCurrentUser = @('SOFTWARE') + $AllTVRegistryData = New-Object System.Collections.ArrayList + } + + Process { + foreach ($searchProgramm in $SearchProgramms) { + foreach ($registrySearchPath in $RegistrySearchPathsLocalMachine) { + $regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$registrySearchPath\$searchProgramm", $false) + if ($regKey) { + Add-Registry -RegKey $regKey -Program $searchProgramm + } + } + + foreach ($registrySearchPath in $RegistrySearchPathsCurrentUser) { + $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm", $false) + if ($searchProgramm -eq 'Blizz' -or $searchProgramm -eq 'TeamViewerMeeting') { + $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm\MachineFallback", $false) + } + if ($regKey) { + Add-Registry -RegKey $regKey -Program $searchProgramm + } + } + + $output = "Windows Registry Editor Version 5.00 `r`n" + foreach ($data in $AllTVRegistryData) { + $output += "[$($data.RegistryPath)]`r`n" + foreach ($entry in $data.Entries) { + if ($null -ne $entry.name) { + $output += """$($entry.Name)""" + $entry.Type + $entry.Value + "`r`n" + } + } + $output += "`r`n" + } + $output | Out-File -FilePath "$OutputPath\Data\TeamViewer_Version15\Reg_Version15.txt" + } + } + +} + + + +function Get-RouteTable { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) +Process{ + try { + $processInfo = New-Object System.Diagnostics.ProcessStartInfo + $processInfo.FileName = 'route.exe' + $processInfo.Arguments = 'print' + $processInfo.WindowStyle = 'Hidden' + $processInfo.UseShellExecute = $false + $processInfo.RedirectStandardOutput = $true + + $process = [System.Diagnostics.Process]::Start($processInfo) + $output = $process.StandardOutput.ReadToEnd() + $output | Out-File "$OutputPath\Data\RouteTable.txt" + } + catch { + Write-Error "An error occurred while collecting RouteTable data: $_" + } +} +} + + + + + +class TeamViewerConfiguration { + [string]$APIUri = 'https://webapi.teamviewer.com/api/v1' + + static [TeamViewerConfiguration] $Instance = $null + + static [TeamViewerConfiguration] GetInstance() { + if (-not [TeamViewerConfiguration]::Instance) { + [TeamViewerConfiguration]::Instance = [TeamViewerConfiguration]::new() + } + + return [TeamViewerConfiguration]::Instance + } +} + +function Get-TeamViewerAPIUri { + $config = [TeamViewerConfiguration]::GetInstance() + return $config.APIUri +} + + + + + +function Get-TeamViewerLinuxGlobalConfig { + param( + [Parameter()] + [string] + $Path = '/opt/teamviewer/config/global.conf', + + [Parameter()] + [string] + $Name + ) + $config = & sudo pwsh -command Get-Content $Path | ForEach-Object { + if ($_ -Match '\[(?\w+)\s*\]\s+(?[\w\\]+)\s+=\s*(?.*)$') { + $Matches.Remove(0) + $entry = [pscustomobject]$Matches + switch ($entry.EntryType) { + 'strng' { + $entry.EntryValue = $entry.EntryValue | ` + Select-String -Pattern '"([^\"]*)"' -AllMatches | ` + Select-Object -ExpandProperty Matches | ` + ForEach-Object { $_.Groups[1].Value } + } + 'int32' { + $entry.EntryValue = [int32]($entry.EntryValue) + } + 'int64' { + #In some cases the EntryName DeviceManagement/TransitionNonces is set to entryvalue '0 0 0 0 0' of type int64 + if ($entry.EntryValue -notmatch '0 0 0 0 0') { + $entry.EntryValue = [int64]($entry.EntryValue) + } + } + } + $entry + } + } + + if ($Name) { + ($config | Where-Object { $_.EntryName -eq $Name }).EntryValue + } + else { + $config + } +} + + + +function Get-TeamViewerRegKeyPath { + param ( + [Parameter()] + [ValidateSet('WOW6432', 'Auto')] + [string] + $Variant = 'Auto' + ) + if (($Variant -eq 'WOW6432') -Or (Test-TeamViewer32on64)) { + Write-Output 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' + } + else { + Write-Output 'HKLM:\SOFTWARE\TeamViewer' + } +} + + + +function Get-TeamViewerServiceName { + Write-Output 'TeamViewer' +} + + + +function Get-TSCDirectoryFile { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + + Process { + $SearchDirectories = Get-TSCSearchDirectory + $TempDirectory = New-Item -Path $OutputPath -Name 'Data' -ItemType Directory -Force + $Endings = @('.log', 'tvinfo.ini', '.mdmp', 'Connections.txt', 'Connections_incoming.txt') + $TmpLogFiles = @() + foreach ($Name in $SearchDirectories.Keys) { + $SearchDirectory = $SearchDirectories[$Name] + foreach ($Folder in $SearchDirectory) { + if (Test-Path -Path $Folder) { + $TempSubdirectory = Join-Path -Path $TempDirectory -ChildPath $Name + New-Item -Path $TempSubdirectory -ItemType Directory -Force | Out-Null + $files = Get-ChildItem -Path $Folder -File -Recurse + foreach ($file in $files) { + foreach ($ending in $Endings) { + if ($file.Name.EndsWith($ending)) { + $tmpLogfilePath = Join-Path -Path $TempSubdirectory -ChildPath $file.Name + Copy-Item -Path $file.FullName -Destination $tmpLogfilePath -Force + $TmpLogFiles += $tmpLogfilePath + Write-Output "Collected log file from $($file.FullName)" + } + } + } + } + } + } + Write-Output 'Files from TeamViewer directories have been collected.' + } +} + + + +function Get-TSCSearchDirectory { + $LocalAppData = [System.Environment]::GetFolderPath('LocalApplicationData') + $RoamingAppData = [System.Environment]::GetFolderPath('ApplicationData') + $TVAppData = Join-Path -Path $LocalAppData.ToString() -ChildPath 'TeamViewer/Logs' + $TVRoamingData = Join-Path -Path $RoamingAppData.ToString() -ChildPath 'TeamViewer' + $InstallationDirectory = Get-TeamViewerInstallationDirectory + + $TSCSearchDirectory = @{ + 'TeamViewer_Version15' = $InstallationDirectory + 'AppData\TeamViewer' = @($TVAppData; $TVRoamingData) + } + + return $TSCSearchDirectory +} + + + +function Get-TypeAndValueOfRegistryValue { + param ( + [Microsoft.Win32.RegistryKey]$RegKey, + [string]$ValueName + ) + + $valueKind = $RegKey.GetValueKind($ValueName) + $type = $valueKind + + if ($valueKind -eq 'DWord') { + $type = "=dword:" + $value = [Convert]::ToInt32($RegKey.GetValue($ValueName)).ToString('x') + } + elseif ($valueKind -eq 'Binary') { + $type = "=hex:" + $value = ($RegKey.GetValue($ValueName) | ForEach-Object { $_.ToString('x2') }) -join ',' + } + elseif ($valueKind -eq 'String') { + $type = "=" + $value = $RegKey.GetValue($ValueName).ToString() + } + elseif ($valueKind -eq 'MultiString') { + $type = "=hex(7):" + $value += ($RegKey.GetValue($ValueName) | ForEach-Object { + $_.ToCharArray() | ForEach-Object { [Convert]::ToInt32($_).ToString('X') + ',00' } + }) -join ',' + $value += ',00,00,' + if ($value.Length -gt 0) { + $value += '00,00' + } + } + else { + $type = "" + $value = $RegKey.GetValue($ValueName).ToString() + } + + return $type, $value +} + + + + +function Invoke-ExternalCommand { + param( + [Parameter(Mandatory = $true, Position = 0)] + [string] + $Command, + + [Parameter(ValueFromRemainingArguments = $true)] + [object[]] + $CommandArgs + ) + & $Command @CommandArgs +} + + + +function Invoke-TeamViewerRestMethod { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [uri] + $Uri, + + [Microsoft.PowerShell.Commands.WebRequestMethod] + $Method, + + [System.Collections.IDictionary] + $Headers, + + [System.Object] + $Body, + + [string] + $ContentType, + + [System.Management.Automation.PSCmdlet] + $WriteErrorTo + + ) + + if (-Not $Headers) { + $Headers = @{ } + $PSBoundParameters.Add('Headers', $Headers) | Out-Null + } + + if ($global:TeamViewerProxyUriSet) { + $Proxy = $global:TeamViewerProxyUriSet + } + elseif ([Environment]::GetEnvironmentVariable('TeamViewerProxyUri') ) { + $Proxy = [Environment]::GetEnvironmentVariable('TeamViewerProxyUri') + if ($global:TeamViewerProxyUriRemoved) { + $Proxy = $null + } + } + If ($Proxy) { + $PSBoundParameters.Add('Proxy', $Proxy) | Out-Null + } + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ApiToken) + $Headers['Authorization'] = "Bearer $([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr))" + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + $PSBoundParameters.Remove('ApiToken') | Out-Null + $PSBoundParameters.Remove('WriteErrorTo') | Out-Null + + $currentTlsSettings = [Net.ServicePointManager]::SecurityProtocol + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + + $currentProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + + + # Using `Invoke-WebRequest` instead of `Invoke-RestMethod`: + # There is a known issue for PUT and DELETE operations to hang on Windows Server 2012. + try { + + return ((Invoke-WebRequest -UseBasicParsing @PSBoundParameters).Content | ConvertFrom-Json) + } + catch { + $msg = $null + if ($PSVersionTable.PSVersion.Major -ge 6) { + $msg = $_.ErrorDetails.Message + } + elseif ($_.Exception.Response) { + $stream = $_.Exception.Response.GetResponseStream() + $reader = New-Object System.IO.StreamReader($stream) + $reader.BaseStream.Position = 0 + $msg = $reader.ReadToEnd() + } + $err = ($msg | ConvertTo-TeamViewerRestError) + if ($WriteErrorTo) { + $WriteErrorTo.WriteError(($err | ConvertTo-ErrorRecord)) + } + else { + throw $err + } + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $currentTlsSettings + $ProgressPreference = $currentProgressPreference + } +} + + + +function Resolve-AssignmentErrorCode { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $exitCode + ) + Begin { + $exitCodeMessages = @{ + 0 = 'Operation successful' + 1 = 'Misspelled or used a wrong command' + 2 = 'Signature verification error' + 3 = 'TeamViewer is not installed' + 4 = 'The assignment configuration could not be verified against the TeamViewer Cloud.Try again later.' + 400 = 'Invalid assignment ID' + 401 = 'TeamViewer service not running' + 402 = 'Service Incompatible Version' + 403 = 'Check your internet connection' + 404 = 'Another assignment process running' + 405 = 'Timeout' + 406 = 'Failed due to unknown reasons' + 407 = 'Access denied. Ensure local administrator rights' + 408 = 'Denied by policy' + } + } + Process { + if ($exitCode) { + if ($exitCodeMessages.ContainsKey($exitCode)) { + Write-Output $exitCodeMessages[$exitCode] + } + else { + Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" + } + } + elseif ($exitCode -eq 0) { + Write-Output $exitCodeMessages[$exitCode] + } + } +} + + + +function Resolve-CustomizationErrorCode { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $exitCode + ) + Begin { + $exitCodeMessages = @{ + 0 = 'Operation successful' + 1 = 'Invalid command line arguments' + 500 = 'An internal error occurred. See TeamViewer log files for more details!' + 501 = 'The current user was denied access' + 502 = 'The download of the custom configuration timed out' + 503 = 'Invalid Module' + 504 = 'Restart of the GUI failed' + 505 = 'Custom configuration failed. See the TeamViewer log files for more details and check if the custom configuration id is still valid.' + 506 = 'Removal of custom configuration failed. See the TeamViewer log files for more details!' + } + } + Process { + if ($exitCode) { + if ($exitCodeMessages.ContainsKey($exitCode)) { + Write-Output $exitCodeMessages[$exitCode] + } + else { + Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" + } + } + elseif ($exitCode -eq 0) { + Write-Output $exitCodeMessages[$exitCode] + } + } +} + + + +function Resolve-TeamViewerContactId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Contact + ) + Process { + if ($Contact.PSObject.TypeNames -contains 'TeamViewerPS.Contact') { + return $Contact.Id + } + elseif ($Contact -is [string]) { + if ($Contact -notmatch 'c[0-9]+') { + throw "Invalid contact identifier '$Contact'. String must be a contact ID in the form 'c123456789'." + } + return $Contact + } + else { + throw "Invalid contact identifier '$Contact'. Must be either a [TeamViewerPS.Contact] or [string]." + } + } +} + + + +function Resolve-TeamViewerDeviceId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Device + ) + Process { + if ($Device.PSObject.TypeNames -contains 'TeamViewerPS.Device') { + return $Device.Id + } + elseif ($Device -is [string]) { + if ($Device -notmatch 'd[0-9]+') { + throw "Invalid device identifier '$Device'. String must be a device ID in the form 'd123456789'." + } + return $Device + } + else { + throw "Invalid device identifier '$Device'. Must be either a [TeamViewerPS.Device] or [string]." + } + } +} + + + +function Resolve-TeamViewerGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Group + ) + Process { + if ($Group.PSObject.TypeNames -contains 'TeamViewerPS.Group') { + return $Group.Id + } + elseif ($Group -is [string]) { + if ($Group -notmatch 'g[0-9]+') { + throw "Invalid group identifier '$Group'. String must be a group ID in the form 'g123456789'." + } + return $Group + } + else { + throw "Invalid group identifier '$Group'. Must be either a [TeamViewerPS.Group] or [string]." + } + } +} + + + +function Resolve-TeamViewerLanguage { + param( + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [object] + $InputObject + ) + Process { + $supportedLanguages = @( + 'bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'hr', 'hu', 'id', 'it', 'ja', + 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'th', 'tr', 'uk', + 'vi', 'zh_CN', 'zh_TW', 'auto') + + $language = $InputObject + if ($InputObject -is [cultureinfo]) { + $language = switch ($InputObject.Name) { + 'zh-CN' { 'zh_CN' } + 'zh-TW' { 'zh_TW' } + default { $InputObject.TwoLetterISOLanguageName } + } + } + + if ($supportedLanguages -notcontains $language) { + throw "Invalid culture '$language'. Supported languages are: $supportedLanguages" + } + + return $language + } +} + + + +function Resolve-TeamViewerManagedDeviceId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $ManagedDevice + ) + Process { + if ($ManagedDevice.PSObject.TypeNames -contains 'TeamViewerPS.ManagedDevice') { + return [guid]$ManagedDevice.Id + } + elseif ($ManagedDevice -is [string]) { + return [guid]$ManagedDevice + } + elseif ($ManagedDevice -is [guid]) { + return $ManagedDevice + } + else { + throw "Invalid managed device identifier '$ManagedDevice'. Must be either a [TeamViewerPS.ManagedDevice], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerManagedGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $ManagedGroup + ) + Process { + if ($ManagedGroup.PSObject.TypeNames -contains 'TeamViewerPS.ManagedGroup') { + return [guid]$ManagedGroup.Id + } + elseif ($ManagedGroup -is [string]) { + return [guid]$ManagedGroup + } + elseif ($ManagedGroup -is [guid]) { + return $ManagedGroup + } + else { + throw "Invalid managed group identifier '$ManagedGroup'. Must be either a [TeamViewerPS.ManagedGroup], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerManagerId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Manager + ) + Process { + if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { + return [guid]$Manager.Id + } + elseif ($Manager -is [string]) { + return [guid]$Manager + } + elseif ($Manager -is [guid]) { + return $Manager + } + else { + throw "Invalid manager identifier '$Manager'. Must be either a [TeamViewerPS.Manager], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerPolicyId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Policy, + + [Parameter()] + [switch] + $AllowNone, + + [Parameter()] + [switch] + $AllowInherit + ) + Process { + if ($Policy.PSObject.TypeNames -contains 'TeamViewerPS.Policy') { + return [guid]$Policy.Id + } + elseif ($Policy -is [string]) { + if ($Policy -eq 'none' -And $AllowNone) { + return 'none' + } + elseif ($Policy -eq 'inherit' -And $AllowInherit) { + return 'inherit' + } + else { + return [guid]$Policy + } + } + elseif ($Policy -is [guid]) { + return $Policy + } + else { + throw "Invalid policy identifier '$Policy'. Must be either a [TeamViewerPS.Policy], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerSsoDomainId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Domain + ) + Process { + if ($Domain.PSObject.TypeNames -contains 'TeamViewerPS.SsoDomain') { + return [guid]$Domain.Id + } + elseif ($Domain -is [string]) { + return [guid]$Domain + } + elseif ($Domain -is [guid]) { + return $Domain + } + else { + throw "Invalid SSO domain identifier '$Domain'. Must be either a [TeamViewerPS.SsoDomain], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerUserEmail { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $false)] + [object] + $User + ) + Process { + if (!$User) { + return $null + } + elseif ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { + return $User.Email + } + elseif ($User -is [string]) { + return $User + } + else { + throw "Invalid user email '$User'. Must be either a [TeamViewerPS.User] or [string]." + } + } +} + + + +function Resolve-TeamViewerUserGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserGroup + ) + Process { + if ($UserGroup.PSObject.TypeNames -contains 'TeamViewerPS.UserGroup') { + return [UInt64]$UserGroup.Id + } + elseif ($UserGroup -is [string]) { + return [UInt64]$UserGroup + } + elseif ($UserGroup -is [UInt64] -or $UserGroup -is [Int64] -or $UserGroup -is [int]) { + return [UInt64]$UserGroup + } + else { + throw "Invalid user group identifier '$UserGroup'. Must be either a [TeamViewerPS.UserGroup], [UInt64], [Int64] or [string]." + } + } +} + + + +function Resolve-TeamViewerUserGroupMemberMemberId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserGroupMember + ) + Process { + if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { + return $UserGroupMember.AccountId + } + elseif ($UserGroupMember -match 'u[0-9]+') { + return $UserGroupMember + } + elseif ($UserGroupMember -is [string]) { + return [int]$UserGroupMember + } + elseif ($UserGroupMember -is [int]) { + return $UserGroupMember + } + else { + throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." + } + } +} + + + +function Resolve-TeamViewerUserId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $User + ) + Process { + if ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { + return $User.Id + } + elseif ($User -is [string]) { + if ($User -notmatch 'u[0-9]+') { + throw "Invalid user identifier '$User'. String must be a user ID in the form 'u123456789'." + } + return $User + } + else { + throw "Invalid user identifier '$User'. Must be either a [TeamViewerPS.User] or [string]." + } + } +} + + + + +function Resolve-TeamViewerUserRoleId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserRole + ) + Process { + if ($UserRole.PSObject.TypeNames -contains 'TeamViewerPS.UserRole') { + return [string]$UserRole.RoleID + } + elseif ($UserRole -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { + return [string]$UserRole + } + else { + throw "Invalid role group identifier '$UserRole'. Must be either a [TeamViewerPS.UserRole] or [UUID] " + } + } +} + + + +$hasTestNetConnection = [bool](Get-Command Test-NetConnection -ErrorAction SilentlyContinue) +$hasTestConnection = [bool](Get-Command Test-Connection -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge 5.1 }) + +function Test-TcpConnection { + param( + [Parameter(Mandatory = $true)] + [string] + $Hostname, + + [Parameter(Mandatory = $true)] + [int] + $Port + ) + + if (-Not $hasTestNetConnection -And -Not $hasTestConnection) { + throw "No suitable cmdlet found for testing the TeamViewer network connectivity." + } + + $oldProgressPreference = $global:ProgressPreference + $global:ProgressPreference = 'SilentlyContinue' + + if ($hasTestNetConnection) { + Test-NetConnection -ComputerName $Hostname -Port $Port -InformationLevel Quiet -WarningAction SilentlyContinue + } + elseif ($hasTestConnection) { + Test-Connection -TargetName $Hostname -TcpPort $Port -Quiet -WarningAction SilentlyContinue + } + else { + $false + } + + $global:ProgressPreference = $oldProgressPreference +} + + + +function Test-TeamViewer32on64 { + if (![Environment]::Is64BitOperatingSystem) { + return $false + } + $registryKey = Get-TeamViewerRegKeyPath -Variant WOW6432 + if (!(Test-Path $registryKey)) { + return $false + } + try { + $installationDirectory = (Get-Item $registryKey).GetValue('InstallationDirectory') + $binaryPath = Join-Path $installationDirectory 'TeamViewer.exe' + return Test-Path $binaryPath + } + catch { + return $false + } +} + + + +function Add-TeamViewerAssignment { + param( + [Parameter(Mandatory = $true)] + [object] + $AssignmentId, + + [string] + $DeviceAlias, + + [int] + $Retries + ) + + + if (Test-TeamViewerInstallation) { + $OS = Get-OperatingSystem + $CurrentDirectory = Get-Location + $installationDirectory = Get-TeamViewerInstallationDirectory + Set-Location $installationDirectory + $CurrentVersion = Get-TeamViewerVersion + $VersionTable = $CurrentVersion.split('.') + if ($OS -eq 'Windows') { + $cmd = "assignment --id $AssignmentId" + $FilePath = 'TeamViewer.exe' + } + elseif ($OS -eq 'Linux') { + $cmd = "teamviewer assignment --id $AssignmentId" + $FilePath = 'sudo' + } + + if ($DeviceAlias) { + if (($VersionTable[0] -eq 15 -and $VersionTable[1] -ge 44) -or $VersionTable[0] -gt 15) { + $cmd += " --device-alias=$DeviceAlias" + } + else { + Write-Error "Current TeamViewer Version: $CurrentVersion does not support the usage of alias. Please update to the latest version." + Set-Location $CurrentDirectory + exit + } + } + if ($Retries) { + $cmd += " --retries=$Retries" + } + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } + else { + Write-Output 'TeamViewer is not installed.' + } +} + + + + + +Function Add-TeamViewerCustomization { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true, ParameterSetName = 'ById')] + [object] + $Id, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByPath')] + [object] + $Path, + + [switch] + $RestartGUI, + + [switch] + $RemoveExisting + ) + + if (Get-OperatingSystem -eq 'Windows') { + if (Test-TeamViewerInstallation) { + $installationDirectory = Get-TeamViewerInstallationDirectory + $currentDirectory = Get-Location + Set-Location $installationDirectory + $cmd = 'customize' + if ($Id) { + $cmd += " --id $Id" + } + elseif ($Path) { + $cmd += " --path $Path" + } + if ($RemoveExisting) { + $cmd += ' --remove' + } + if ($RestartGUI) { + $cmd += ' --restart-gui' + } + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + Set-Location $currentDirectory + } + else { + Write-Error 'TeamViewer is not installed' + } + } + else { + Write-Error 'Customization is currently supported only on Windows.' + } +} + + + +function Add-TeamViewerManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices" + + $body = @{ + id = $deviceId + } + + if ($PSCmdlet.ShouldProcess($deviceId, "Add device to managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Add-TeamViewerManager { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByAccountId')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] + [string] + $AccountId, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagerId } )] + [Alias("ManagerId")] + [object] + $Manager, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [object] + $User, + + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId })] + [Alias('UserGroupId')] + [object] + $UserGroup, + + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter()] + [AllowEmptyCollection()] + [string[]] + $Permissions + ) + + $resourceUri = $null + switch -Wildcard ($PSCmdlet.ParameterSetName) { + 'Device*' { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" + $processMessage = "Add manager to managed device" + } + 'Group*' { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" + $processMessage = "Add manager to managed group" + } + } + + $body = @{} + switch -Wildcard ($PSCmdlet.ParameterSetName) { + '*ByAccountId' { + $body["accountId"] = $AccountId.TrimStart('u') + } + '*ByManagerId' { + $body["id"] = $Manager | Resolve-TeamViewerManagerId + } + '*ByUserObject' { + $body["accountId"] = ( $User | Resolve-TeamViewerUserId ).TrimStart('u') + } + '*ByUserGroupId' { + $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId + } + } + + if ($Permissions) { + $body["permissions"] = @($Permissions) + } + else { + $body["permissions"] = @() + } + + if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @($body)))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Add-TeamViewerRoleToAccount { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias('Id', 'UserIds')] + [string[]] + $Accounts + ) + + Begin { + $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" + $AccountsToAdd = @() + $body = @{ + UserIds = @() + UserRoleId = $id + } + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($Accounts, 'Assign Account to Role')) { + if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { + $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } + } + foreach ($Account in $Accounts) { + $AccountsToAdd += $Account + $body.UserIds = @($AccountsToAdd) + } + } + if ($AccountsToAdd.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $AccountsToAdd = @() + } + } + End { + if ($AccountsToAdd.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + + +function Add-TeamViewerRoleToUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRoleId')] + [object] + $UserRole, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup + ) + + Begin { + $RoleId = $UserRole | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" + $body = @{ + UserRoleId = $RoleId + UserGroupId = $UserGroup + + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($UserGroup, 'Assign Role to User Group')) { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } +} + + + +function Add-TeamViewerSsoExclusion { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [string[]] + $Email + ) + Begin { + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" + $emailsToAdd = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-RequestInternal { + $body = @{ + emails = @($emailsToAdd) + } + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } + Process { + if ($PSCmdlet.ShouldProcess($Email, "Add SSO exclusion")) { + $emailsToAdd += $Email + } + if ($emailsToAdd.Length -eq 100) { + Invoke-RequestInternal + $emailsToAdd = @() + } + } + End { + if ($emailsToAdd.Length -gt 0) { + Invoke-RequestInternal + } + } +} + + + +function Add-TeamViewerUserGroupMember { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [object[]] + [Alias('UserGroupMemberId')] + [Alias('UserGroupMember')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] + $Member + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToAdd = @() + $body = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) + } + } + + Process { + # when members are provided as pipeline input, each member is provided as a separate statement, + # thus the members should be combined into one array in order to send a single request. + if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { + if ($Member -notmatch 'u[0-9]+') { + ForEach-Object { + $Member = [int[]]$Member + } + } + else { + ForEach-Object { + $Member = [int[]]$Member.trim('u') + } + } + if ($Member -isnot [array]) { + $membersToAdd = @([UInt32]$Member) + } + else { + $membersToAdd += [UInt32[]]$Member + } + $payload = $membersToAdd -join ', ' + $body = "[$payload]" + } + + # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` + # in order to accept more members + if ($membersToAdd.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $membersToAdd = @() + } + } + + End { + # A request needs to be sent if there were less than 100 members + if ($membersToAdd.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + +function Connect-TeamViewerApi { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + if (Invoke-TeamViewerPing -ApiToken $ApiToken) { + $global:PSDefaultParameterValues["*-Teamviewer*:ApiToken"] = $ApiToken + } +} + + +function Disconnect-TeamViewerApi { + $global:PSDefaultParameterValues.Remove("*-Teamviewer*:ApiToken") +} + + +function Export-TeamViewerSystemInformation { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $TargetDirectory + ) + Process { + if (Test-TeamViewerInstallation ) { + if (Get-OperatingSystem -eq 'Windows') { + $Temp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.Guid]::NewGuid().ToString()) + $CurrentDirectory = Get-Location + $Temp | Get-TSCDirectoryFile + $Temp | Get-InstalledSoftware + $Temp | Get-IpConfig + $Temp | Get-MSInfo32 + $Temp | Get-HostFile + $Temp | Get-NSLookUpData + $Temp | Get-RouteTable + $Temp | Get-RegistryPath + $ClientID = Get-ClientId + $ZipFileName = 'TV_SC_' + $ClientID + '_WINPS.zip' + $ZipPath = Join-Path -Path "$Temp\Data" -ChildPath $ZipFileName + Compress-Archive -Path $Temp\* -DestinationPath $ZipPath -Force + if ($TargetDirectory -and (Test-Path $TargetDirectory)) { + Copy-Item -Path $ZipPath -Destination $TargetDirectory -Force + } + else { + Copy-Item -Path $ZipPath -Destination $CurrentDirectory -Force + } + } + else { + Write-Error 'Currently this functionality is supported only on Windows.' + } + } + else { + Write-Error 'TeamViewer is not installed.' + } + } +} + + + +function Get-TeamViewerAccount { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/account" + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerAccount) +} + + + +function Get-TeamViewerConnectionReport { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $false)] + [string] + $UserName, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("User")] + [object] + $UserId, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("Group")] + [object] + $GroupId, + + [Parameter(Mandatory = $false)] + [string] + $DeviceName, + + [Parameter(Mandatory = $false)] + [int] + $DeviceId, + + [Parameter(Mandatory = $false)] + [switch] + $WithSessionCode, + + [Parameter(Mandatory = $false)] + [switch] + $WithoutSessionCode, + + [Parameter(Mandatory = $false)] + [string] + $SessionCode, + + [Parameter(Mandatory = $false)] + [TeamViewerConnectionReportSessionType] + $SupportSessionType, + + [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] + [DateTime] + $StartDate, + + [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [DateTime] + $EndDate = (Get-Date), + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 12)] + [int] + $Months, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 31)] + [int] + $Days, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 24)] + [int] + $Hours, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 60)] + [int] + $Minutes, + + [Parameter(Mandatory = $false)] + [ValidateRange(1, [int]::MaxValue)] + [int] + $Limit + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/reports/connections"; + + $parameters = @{} + + if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { + $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) + } + if ($StartDate -And $EndDate -And $StartDate -lt $EndDate) { + $parameters.from_date = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + $parameters.to_date = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + } + + if ($UserName) { + $parameters.username = $UserName + } + + if ($UserId) { + $parameters.userid = $UserId | Resolve-TeamViewerUserId + } + + if ($DeviceName) { + $parameters.devicename = $DeviceName + } + + if ($DeviceId) { + $parameters.deviceid = $DeviceId + } + + if ($GroupId) { + $parameters.groupid = $GroupId | Resolve-TeamViewerGroupId + } + + if ($WithSessionCode -And !$WithoutSessionCode) { + $parameters.has_code = $true + } + elseif ($WithoutSessionCode -And !$WithSessionCode) { + $parameters.has_code = $false + } + + if ($SessionCode) { + $parameters.session_code = $SessionCode + } + + if ($SupportSessionType) { + $parameters.support_session_type = [int]$SupportSessionType + } + + $remaining = $Limit + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $results = ($response.records | ConvertTo-TeamViewerConnectionReport) + if ($Limit) { + Write-Output ($results | Select-Object -First $remaining) + $remaining = $remaining - @($results).Count + } + else { + Write-Output $results + } + $parameters.offset_id = $response.next_offset + } while ($parameters.offset_id -And (!$Limit -Or $remaining -gt 0)) +} + + + +function Get-TeamViewerContact { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByContactId")] + [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] + [Alias("ContactId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [Alias("PartialName")] + [string] + $Name, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateSet('Online', 'Busy', 'Away', 'Offline')] + [string] + $FilterOnlineState, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/contacts"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByContactId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($Name) { + $parameters['name'] = $Name + } + if ($FilterOnlineState) { + $parameters['online_state'] = $FilterOnlineState.ToLower() + } + if ($Group) { + $groupId = $Group | Resolve-TeamViewerGroupId + $parameters['groupid'] = $groupId + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($response.contacts | ConvertTo-TeamViewerContact) +} + + + +function Get-TeamViewerCustomModuleId { + + if (Test-TeamViewerinstallation) { + $fileName = 'TeamViewer.json' + $installationDirectory = Get-TeamViewerInstallationDirectory + $filePath = Join-Path -Path $installationDirectory -ChildPath $fileName + if (Test-Path -Path $filePath) { + $jsonContent = Get-Content -Path $FilePath -Raw + $jsonObject = ConvertFrom-Json $jsonContent + if ($jsonObject.id) { + return $jsonObject.id + } + } + else { + Write-Error 'Custom module Id cannot be found. Check if customization is applied.' + } + } + else { + Write-Error 'TeamViewer is not installed' + } + +} + + + +function Get-TeamViewerDevice { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] + [Alias("DeviceId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [int] + $TeamViewerId, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateSet('Online', 'Busy', 'Away', 'Offline')] + [string] + $FilterOnlineState, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/devices"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($TeamViewerId) { + $parameters['remotecontrol_id'] = "r$TeamViewerId" + } + if ($FilterOnlineState) { + $parameters['online_state'] = $FilterOnlineState.ToLower() + } + if ($Group) { + $groupId = $Group | Resolve-TeamViewerGroupId + $parameters['groupid'] = $groupId + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($response.devices | ConvertTo-TeamViewerDevice) +} + + + +function Get-TeamViewerEventLog { + [CmdletBinding(DefaultParameterSetName = "RelativeDates")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] + [DateTime] + $StartDate, + + [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [DateTime] + $EndDate = (Get-Date), + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 12)] + [int] + $Months, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 31)] + [int] + $Days, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 24)] + [int] + $Hours, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 60)] + [int] + $Minutes, + + [Parameter(Mandatory = $false)] + [int] + $Limit, + + [Parameter(Mandatory = $false)] + [ArgumentCompleter( { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + @( + 'AddRemoteWorkerDevice', + 'ChangedDisabledRemoteInput', + 'ChangedShowBlackScreen', + 'CompanyAddressBookDisabled', + 'CompanyAddressBookEnabled', + 'CompanyAddressBookMembersHid', + 'CompanyAddressBookMembersUnhid' + 'ConditionalAccessBlockMeetingStateChanged', + 'ConditionalAccessDirectoryGroupAdded', + 'ConditionalAccessDirectoryGroupDeleted', + 'ConditionalAccessDirectoryGroupMembersAdded', + 'ConditionalAccessDirectoryGroupMembersDeleted', + 'ConditionalAccessRuleAdded', + 'ConditionalAccessRuleDeleted', + 'ConditionalAccessRuleModified', + 'ConditionalAccessRuleVerificationStateChanged', + 'CreateCustomHost', + 'DeleteCustomHost', + 'EditOwnProfile', + 'EditTFAUsage', + 'EditUserPermissions', + 'EditUserProperties', + 'EmailConfirmed', + 'EndedRecording', + 'EndedSession', + 'GroupAdded', + 'GroupDeleted', + 'GroupShared', + 'GroupUpdated', + 'IncomingSession', + 'JoinCompany', + 'JoinedSession', + 'LeftSession', + 'ParticipantJoinedSession', + 'ParticipantLeftSession', + 'PausedRecording', + 'PolicyAdded', + 'PolicyDeleted', + 'PolicyUpdated', + 'ReceivedDisabledLocalInput', + 'ReceivedFile', + 'ReceivedShowBlackScreen', + 'RemoveRemoteWorkerDevice', + 'ResumedRecording', + 'ScriptTokenAdded', + 'ScriptTokenDeleted', + 'ScriptTokenUpdated', + 'SentFile', + 'StartedRecording', + 'StartedSession', + 'SwitchedSides', + 'UpdateCustomHost', + 'UserCreated', + 'UserDeleted', + 'UserGroupCreated', + 'UserGroupDeleted', + 'UserGroupMembersAdded', + 'UserGroupMembersRemoved', + 'UserGroupUpdated', + 'UserRemovedFromCompany' + ) | Where-Object { $_ -like "$wordToComplete*" } + } )] + [string[]] + $EventNames, + + [Parameter(Mandatory = $false)] + [ArgumentCompleter( { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + @( + "CompanyAddressBook", + "CompanyAdministration", + "ConditionalAccess", + "CustomModules", + "GroupManagement", + "LicenseManagement", + "Policy", + "Session", + "UserGroups", + "UserProfile" + ) | Where-Object { $_ -like "$wordToComplete*" } + })] + [string[]] + $EventTypes, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerUserEmail } )] + [Alias("Users")] + [object[]] + $AccountEmails, + + [Parameter(Mandatory = $false)] + [string] + $AffectedItem, + + [Parameter(Mandatory = $false)] + [Alias("RemoteControlSession")] + [guid] + $RemoteControlSessionId + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/EventLogging"; + + $Limit = if ($Limit -lt 0) { $null } else { $Limit } + + if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { + $Hours = if (!$Months -And !$Days -And !$Hours -And !$Minutes) { 1 } else { $Hours } + $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) + } + + $parameters = @{ + StartDate = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + EndDate = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + } + + if ($EventNames) { + $parameters.EventNames = $EventNames + } + if ($EventTypes) { + $parameters.EventTypes = $EventTypes + } + if ($AccountEmails) { + $parameters.AccountEmails = @($AccountEmails | Resolve-TeamViewerUserEmail) + } + if ($AffectedItem) { + $parameters.AffectedItem = $AffectedItem + } + if ($RemoteControlSessionId) { + $parameters.RCSessionGuid = $RemoteControlSessionId + } + + $remaining = $Limit + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($parameters | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $results = ($response.AuditEvents | ConvertTo-TeamViewerAuditEvent) + if ($Limit) { + Write-Output ($results | Select-Object -First $remaining) + $remaining = $remaining - @($results).Count + } + else { + Write-Output $results + } + $parameters.ContinuationToken = $response.ContinuationToken + } while ($parameters.ContinuationToken -And (!$Limit -Or $remaining -gt 0)) +} + + + +function Get-TeamViewerGroup { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByGroupId")] + [Alias("GroupId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [Alias("PartialName")] + [string] + $Name, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateSet('OnlyShared', 'OnlyNotShared')] + [string] + $FilterShared + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/groups"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByGroupId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($Name) { + $parameters['name'] = $Name + } + switch ($FilterShared) { + 'OnlyShared' { $parameters['shared'] = $true } + 'OnlyNotShared' { $parameters['shared'] = $false } + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { + Write-Output ($response | ConvertTo-TeamViewerGroup) + } + else { + Write-Output ($response.groups | ConvertTo-TeamViewerGroup) + } +} + + + +function Get-TeamViewerId { + if (Test-TeamViewerInstallation) { + switch (Get-OperatingSystem) { + 'Windows' { + Write-Output (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'ClientID') + } + 'Linux' { + Write-Output (Get-TeamViewerLinuxGlobalConfig -Name 'ClientID') + } + } + } +} + + + +function Get-TeamViewerInstallationDirectory { + switch (Get-OperatingSystem) { + 'Windows' { + $regKey = Get-TeamViewerRegKeyPath + $installationDirectory = if (Test-Path $regKey) { + (Get-Item $regKey).GetValue('InstallationDirectory') + } + if ( + $installationDirectory -And ` + (Test-Path "$installationDirectory/TeamViewer.exe") + ) { + return $installationDirectory + } + } + 'Linux' { + if ( + (Test-Path '/opt/teamviewer/tv_bin/TeamViewer') + ) { + return '/opt/teamviewer/tv_bin/' + } + } + default { + Write-Error 'TeamViewer not installed' + } + } +} + + + + +function Get-TeamViewerLogFilePath { + param( + [switch] + $OpenFile + ) + + if (Test-TeamViewerInstallation) { + if (Get-OperatingSystem -eq 'Windows') { + $SearchDirectories = Get-TSCSearchDirectory + $LogFiles = New-Object System.Collections.ArrayList + foreach ($Name in $SearchDirectories.Keys) { + $SearchDirectory = $SearchDirectories[$Name] + foreach ($Folder in $SearchDirectory) { + if (Test-Path -Path $Folder) { + $files = Get-ChildItem -Path $Folder -File -Recurse + foreach ($file in $files) { + if ($file.Name.EndsWith('.log')) { + $LogFiles.add($file.FullName) | Out-Null + } + } + } + } + } + + if ($OpenFile) { + $LogFile = $host.ui.PromptForChoice('Select file', 'Choose file:', ` + @($LogFiles), 0) + Invoke-Item -Path $LogFiles[$LogFile] + } + else { + return $LogFiles + } + } + } + else { + Write-Error 'TeamViewer is not installed.' + } +} + + + +function Get-TeamViewerManagedDevice { + [CmdletBinding(DefaultParameterSetName = "List")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [Alias("Device")] + [guid] + $Id, + + [Parameter(Mandatory = $true, ParameterSetName = "ListGroup")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(ParameterSetName = "ListGroup")] + [switch] + $Pending + ) + + # default is 'List': + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices"; + $parameters = @{ } + $isListOperation = $true + + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + $resourceUri += "/$Id" + $parameters = $null + $isListOperation = $false + } + 'ListGroup' { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/$(if ($Pending) { "pending-" })devices" + } + } + + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByDeviceId') { + Write-Output ($response | ConvertTo-TeamViewerManagedDevice) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerManagedDevice) + } + } while ($isListOperation -And $parameters.paginationToken) +} + + + +function Get-TeamViewerManagedGroup { + [CmdletBinding(DefaultParameterSetName = "List")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByGroupId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } ) ] + [Alias("GroupId")] + [guid] + $Id, + + [Parameter(ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByGroupId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'ByDeviceId' { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/groups" + } + } + + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { + Write-Output ($response | ConvertTo-TeamViewerManagedGroup) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerManagedGroup) + } + } while ($PsCmdlet.ParameterSetName -In @('List', 'ByDeviceId') ` + -And $parameters.paginationToken) +} + + + +function Get-TeamViewerManagementId { + if (Test-TeamViewerInstallation) { + switch (Get-OperatingSystem) { + 'Windows' { + $regKeyPath = Join-Path (Get-TeamViewerRegKeyPath) 'DeviceManagementV2' + $regKey = if (Test-Path -LiteralPath $regKeyPath) { Get-Item -Path $regKeyPath } + if ($regKey) { + $unmanaged = [bool]($regKey.GetValue('Unmanaged')) + $managementId = $regKey.GetValue('ManagementId') + } + } + 'Linux' { + $unmanaged = [bool](Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\Unmanaged') + $managementId = Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\ManagementId' + } + } + if (!$unmanaged -And $managementId) { + Write-Output ([guid]$managementId) + } + } +} + + + +function Get-TeamViewerManager { + [CmdletBinding(DefaultParameterSetName = "ByDeviceId")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true, ParameterSetName = "ByGroupId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $resourceUri = $null + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" + } + 'ByGroupId' { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + Write-Output ($response.resources | ConvertTo-TeamViewerManager -DeviceId $deviceId) + } + 'ByGroupId' { + Write-Output ($response.resources | ConvertTo-TeamViewerManager -GroupId $groupId) + } + } +} + + + +function Get-TeamViewerPolicy { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByPolicyId")] + [Alias("PolicyId")] + [guid] + $Id + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByPolicyId' { + $resourceUri += "/$Id" + $parameters = $null + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($response.policies | ConvertTo-TeamViewerPolicy) +} + + + + +function Get-TeamViewerRoleAssignmentToAccount { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [string] + $UserRoleId + ) + + + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$UserRoleId" + $parameters = $null + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($response.ContinuationToken) { + $resourceUri += '&continuationToken=' + $response.ContinuationToken + } + Write-Output ($response.AssignedToUsers | ConvertTo-TeamViewerRoleAssignedUser ) + }while ($response.ContinuationToken) +} + + + +function Get-TeamViewerRoleAssignmentToUserGroup { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript({ $_ | Resolve-TeamviewerUserRoleId })] + [Alias('UserRole')] + [string] + $UserRoleId + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$UserRoleId" + $parameters = $null + } + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($response.ContinuationToken) { + $resourceUri += "&continuationToken=" + $response.ContinuationToken + } + Write-Output ($response.AssignedToGroups | ConvertTo-TeamViewerRoleAssignedUserGroup ) + }while ($response.ContinuationToken) + } +} + + + +function Get-TeamViewerService { + switch (Get-OperatingSystem) { + 'Windows' { + Get-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon status + } + } +} + + + +function Get-TeamViewerSsoDomain { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain"; + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response.domains | ConvertTo-TeamViewerSsoDomain) +} + + + +function Get-TeamViewerSsoExclusion { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId + ) + + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion"; + $parameters = @{ } + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output $response.emails + $parameters.ct = $response.continuation_token + } while ($parameters.ct) +} + + + +function Get-TeamViewerUser { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByUserId")] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [Alias("PartialName")] + [string] + $Name, + + [Parameter(ParameterSetName = "FilteredList")] + [string[]] + $Email, + + [Parameter(ParameterSetName = "FilteredList")] + [string[]] + $Permissions, + + [Parameter()] + [ValidateSet("All", "Minimal")] + $PropertiesToLoad = "All" + ) + + $parameters = @{ } + switch ($PropertiesToLoad) { + "All" { $parameters.full_list = $true } + "Minimal" { } + } + + $resourceUri = "$(Get-TeamViewerApiUri)/users" + + switch ($PsCmdlet.ParameterSetName) { + "ByUserId" { + $resourceUri += "/$Id" + $parameters = $null + } + "FilteredList" { + if ($Name) { + $parameters['name'] = $Name + } + if ($Email) { + $parameters['email'] = ($Email -join ',') + } + if ($Permissions) { + $parameters['permissions'] = ($Permissions -join ',') + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq "ByUserId") { + Write-Output ($response | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) + } + else { + Write-Output ($response.users | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) + } +} + + + +function Get-TeamViewerUserGroup { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" + $parameters = @{ } + $isListOperation = $true + + if ($UserGroup) { + $GroupId = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri += "/$GroupId" + $parameters = $null + $isListOperation = $false + } + } + + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($UserGroup) { + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerUserGroup) + } + } while ($isListOperation -And $parameters.paginationToken) + } +} + + + +function Get-TeamViewerUserGroupMember { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $parameters = @{ } + } + + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerUserGroupMember) + } while ($parameters.paginationToken) + } +} + + + +function Get-TeamViewerUserRole { + [CmdletBinding(DefaultParameterSetName = '')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + Begin{ + $parameters = @{ } + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + } + +Process{ + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response.Roles | ConvertTo-TeamViewerUserRole ) +} +} + + + +function Get-TeamViewerVersion { + if (Test-TeamViewerInstallation) { + switch (Get-OperatingSystem) { + 'Windows' { + return (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'Version') + } + 'Linux' { + return (Get-TeamViewerLinuxGlobalConfig -Name 'Version') + } + } + } +} + + + +function Invoke-TeamViewerPackageDownload { + Param( + [Parameter()] + [ValidateSet('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')] + [ValidateScript( { + if (($_ -ne 'Full') -And ((Get-OperatingSystem) -ne 'Windows')) { + $PSCmdlet.ThrowTerminatingError( + ("PackageType parameter is only supported on Windows platforms" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $true + })] + [string] + $PackageType, + + [Parameter()] + [ValidateScript( { + if ((Get-OperatingSystem) -ne 'Windows') { + $PSCmdlet.ThrowTerminatingError( + ("MajorVersion parameter is only supported on Windows platforms" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if($PackageType -eq 'MSI32' -or 'MSI64' ){ + $PSCmdlet.ThrowTerminatingError( + ("MajorVersion parameter is not supported for MSI packages" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($_ -lt 14) { + $PSCmdlet.ThrowTerminatingError( + ("Unsupported TeamViewer version $_" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $true + } )] + [int] + $MajorVersion, + + [Parameter()] + [string] + $TargetDirectory = (Get-Location).Path, + + [Parameter()] + [switch] + $Force + ) + + if ((-not $PackageType) -And ((Get-OperatingSystem) -eq 'Windows')) { + $Package = $host.ui.PromptForChoice('Select Package Type', 'Choose a package type:', ` + @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit'), 0) + $PackageType = @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')[$Package] + } + + $additionalPath = '' + switch (Get-OperatingSystem) { + 'Windows' { + $filename = switch ($PackageType) { + 'Full' { 'TeamViewer_Setup.exe' } + 'MSI32' { 'TeamViewer_MSI32.zip' } + 'MSI64' { 'TeamViewer_MSI64.zip' } + 'Host' { 'TeamViewer_Host_Setup.exe' } + 'Portable' { 'TeamViewerPortable.zip' } + 'QuickJoin' { 'TeamViewerQJ.exe' } + 'QuickSupport' { 'TeamViewerQS.exe' } + 'Full64Bit' { 'TeamViewer_Setup_x64.exe' } + } + if ($MajorVersion) { + $additionalPath = "/version_$($MajorVersion)x" + } + if(($PackageType -eq 'MSI32' -or 'MSI64' )){ + $additionalPath = '/version_15x' + } + } + 'Linux' { + $releaseInfo = (Get-Content /etc/*-release) + $filename = switch -Regex ($releaseInfo) { + 'debian|ubuntu' { + $platform = if ([Environment]::Is64BitOperatingSystem) { 'amd64' } else { 'i386' } + "teamviewer_$platform.deb" + } + 'centos|rhel|fedora' { + $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } + "teamviewer.$platform.rpm" + } + 'suse|opensuse' { + $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } + "teamviewer-suse.$platform.rpm" + } + } + $filename = $filename | Select-Object -First 1 + $additionalPath = '/linux' + } + } + + $downloadUrl = "https://dl.teamviewer.com/download$additionalPath/$filename" + $targetFile = Join-Path $TargetDirectory $filename + + if ((Test-Path $targetFile) -And -Not $Force -And ` + -Not $PSCmdlet.ShouldContinue("File $targetFile already exists. Override?", "Override existing file?")) { + return + } + + Write-Verbose "Downloading $downloadUrl to $targetFile" + $client = New-Object System.Net.WebClient + $client.DownloadFile($downloadUrl, $targetFile) + Write-Output $targetFile +} + + + +function Invoke-TeamViewerPing { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/ping" + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output $result.token_valid +} + + + +function New-TeamViewerContact { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter()] + [switch] + $Invite + ) + + $body = @{ + email = $Email + groupid = $Group | Resolve-TeamViewerGroupId + } + if ($Invite) { + $body['invite'] = $true + } + + $resourceUri = "$(Get-TeamViewerApiUri)/contacts" + if ($PSCmdlet.ShouldProcess($Email, "Create contact")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response | ConvertTo-TeamViewerContact) + Write-Output $result + } +} + + + +function New-TeamViewerDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [int] + $TeamViewerId, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter()] + [Alias("Alias")] + [string] + $Name, + + [Parameter()] + [string] + $Description, + + [Parameter()] + [securestring] + $Password + ) + + $body = @{ + remotecontrol_id = "r$TeamViewerId" + groupid = $Group | Resolve-TeamViewerGroupId + } + + if ($Name) { + $body['alias'] = $Name + } + if ($Description) { + $body['description'] = $Description + } + if ($Password) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + + $resourceUri = "$(Get-TeamViewerApiUri)/devices" + if ($PSCmdlet.ShouldProcess($TeamViewerId, "Create device entry")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response | ConvertTo-TeamViewerDevice) + Write-Output $result + } +} + + + +function New-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias("PolicyId")] + [object] + $Policy + ) + + $body = @{ name = $Name } + if ($Policy) { + $body["policy_id"] = $Policy | Resolve-TeamViewerPolicyId + } + + $resourceUri = "$(Get-TeamViewerApiUri)/groups" + if ($PSCmdlet.ShouldProcess($Name, "Create group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerGroup) + } +} + + + +function New-TeamViewerManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name + ) + + $body = @{ name = $Name } + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" + if ($PSCmdlet.ShouldProcess($Name, "Create managed group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerManagedGroup) + } +} + + + +function New-TeamViewerPolicy { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name, + + [Parameter()] + [AllowEmptyCollection()] + [object[]] + $Settings, + + [Parameter()] + [switch] + $DefaultPolicy = $False + ) + + $body = @{ + name = $Name + default = [boolean]$DefaultPolicy + settings = @() + } + + if ($Settings) { + $body.settings = @($Settings) + } + + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies" + if ($PSCmdlet.ShouldProcess($Name, "Create policy")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function New-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "WithPassword")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(Mandatory = $true)] + [Alias('DisplayName')] + [string] + $Name, + + [Parameter(Mandatory = $true, ParameterSetName = "WithPassword")] + [securestring] + $Password, + + [Parameter(ParameterSetName = "WithoutPassword")] + [Alias('NoPassword')] + [switch] + $WithoutPassword, + + [Parameter()] + [securestring] + $SsoCustomerIdentifier, + + [Parameter()] + [array] + $Permissions, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] + [cultureinfo] + $Culture + ) + + if (-Not $Culture) { + try { $Culture = Get-Culture } + catch { $Culture = 'en' } + } + + $body = @{ + email = $Email + name = $Name + language = $Culture | Resolve-TeamViewerLanguage + permissions = $Permissions -join ',' + } + + if ($Password -And -Not $WithoutPassword) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + + if ($SsoCustomerIdentifier) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) + $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + + $resourceUri = "$(Get-TeamViewerApiUri)/users" + if ($PSCmdlet.ShouldProcess("$Name <$Email>", "Create user")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response | ConvertTo-TeamViewerUser) + $result.Email = $Email + Write-Output $result + } +} + + + +function New-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" + $body = @{ name = $Name } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, "Create user group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + } +} + + + + +function New-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true )] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('UserRoleName')] + [string] + $Name, + + [Parameter(Mandatory = $false)] + [AllowEmptyCollection()] + [object[]] + $Permissions + ) + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + $body = @{ + Name = $Name + Permissions = @() + } + + if ($Permissions) { + $body.Permissions = @($Permissions) + } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, 'Create User Role')) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response.Role | ConvertTo-TeamViewerUserRole) + Write-Output $result + } + } + +} + + + +function Publish-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [object[]] + $User, + + [Parameter()] + [ValidateSet("read", "readwrite")] + $Permissions = "read" + ) + + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Permissions + + $groupId = $Group | Resolve-TeamViewerGroupId + $userIds = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/share_group" + $body = @{ + users = @($userIds | ForEach-Object { @{ + userid = $_ + permissions = $Permissions + } }) + } + + if ($PSCmdlet.ShouldProcess($userids, "Add group share")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Remove-TeamViewerAssignment { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + + if (Test-TeamViewerInstallation) { + $OS = Get-OperatingSystem + $CurrentDirectory = Get-Location + $installationDirectory = Get-TeamViewerInstallationDirectory + Set-Location $installationDirectory + if ($OS -eq 'Windows') { + $cmd = 'unassign' + $FilePath = 'TeamViewer.exe' + } + elseif ($OS -eq 'Linux') { + $cmd = 'teamviewer unassign' + $FilePath = 'sudo' + } + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } + else { + Write-Output 'TeamViewer is not installed.' + } +} + + + + + +function Remove-TeamViewerContact { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] + [Alias("ContactId")] + [Alias("Id")] + [object] + $Contact + ) + Process { + $contactId = $Contact | Resolve-TeamViewerContactId + $resourceUri = "$(Get-TeamViewerApiUri)/contacts/$contactId" + if ($PSCmdlet.ShouldProcess($contactId, "Remove contact")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerCustomization { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if (Get-OperatingSystem -eq 'Windows') { + if (Test-TeamViewerInstallation) { + $installationDirectory = Get-TeamViewerInstallationDirectory + $currentDirectory = Get-Location + Set-Location $installationDirectory + $cmd = 'customize --remove' + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + Set-Location $currentDirectory + } + else { + Write-Error 'TeamViewer is not installed' + } + } + else { + Write-Error 'Customization is currently supported only on Windows.' + } +} + + + +function Remove-TeamViewerDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] + [Alias("DeviceId")] + [Alias("Id")] + [object] + $Device + ) + Process { + $deviceId = $Device | Resolve-TeamViewerDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" + if ($PSCmdlet.ShouldProcess($deviceId, "Remove device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group + ) + Process { + $groupId = $Group | Resolve-TeamViewerGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Remove group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $groupId = $Group | Resolve-TeamViewerManagedGroupId + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($deviceId, "Remove device from managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManagedDeviceManagement { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias('DeviceId')] + [object] + $Device + ) + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($deviceId, 'Remove Management from a device (clears all managers and groups)')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group + ) + Process { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Remove managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManager { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "ByDeviceId")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { + if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { + $PSCmdlet.ThrowTerminatingError( + ("Invalid manager object. Manager must be a group or device manager." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $_ | Resolve-TeamViewerManagerId + })] + [Alias("ManagerId")] + [Alias("Id")] + [object] + $Manager, + + [Parameter(ParameterSetName = 'ByDeviceId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(ParameterSetName = 'ByGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] + [Alias("GroupId")] + [object] + $Group + ) + Process { + $deviceId = $null + $groupId = $null + if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { + if ($Device -Or $Group) { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($Manager.DeviceId) { + $deviceId = $Manager.DeviceId + } + elseif ($Manager.GroupId) { + $groupId = $Manager.GroupId + } + } + elseif ($Device) { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + } + elseif ($Group) { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + } + else { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $managerId = $Manager | Resolve-TeamViewerManagerId + if ($deviceId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" + $processMessage = "Remove manager from managed device" + } + elseif ($groupId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" + $processMessage = "Remove manager from managed group" + } + + if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerPolicy { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('PolicyId')] + [object] + $Policy + ) + Process { + $policyId = $Policy | Resolve-TeamViewerPolicyId + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" + + if ($PSCmdlet.ShouldProcess($policyId, "Delete policy")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamviewerPolicyFromManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [PolicyType] + $PolicyType + ) + Begin { + $body = @{ + 'policy_type' = [int]$PolicyType + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/policy/remove" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerPSProxy { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + $global:TeamViewerProxyUriRemoved = $true + $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ + $global:TeamViewerProxyUriSet = $null + $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + [Environment]::SetEnvironmentVariable('TeamViewerProxyUri','', 'User') + } +} + + + +function Remove-TeamViewerRoleFromAccount { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias('Id', 'UserIds')] + [string[]] + $Accounts + ) + + Begin { + $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" + $AccountsToRemove = @() + $body = @{ + UserIds = @() + UserRoleId = $id + } + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + + } + + Process { + if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from Role')) { + if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { + $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } + } + foreach ($Account in $Accounts) { + $AccountsToRemove += $Account + $body.UserIds = @($AccountsToRemove) + } + } + if ($AccountsToRemove.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $AccountsToRemove = @() + } + } + End { + if ($AccountsToRemove.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + +function Remove-TeamViewerRoleFromUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup + ) + + Begin { + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/usergroup" + $body = @{ + UserGroupId = $UserGroup + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign Role from User Group')) { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } +} + + + +function Remove-TeamViewerSsoExclusion { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [string[]] + $Email + ) + Begin { + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" + $emailsToRemove = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-RequestInternal { + $body = @{ + emails = @($emailsToRemove) + } + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } + Process { + if ($PSCmdlet.ShouldProcess($Email, "Remove SSO exclusion")) { + $emailsToRemove += $Email + } + if ($emailsToRemove.Length -eq 100) { + Invoke-RequestInternal + $emailsToRemove = @() + } + } + End { + if ($emailsToRemove.Length -gt 0) { + Invoke-RequestInternal + } + } +} + + + +function Remove-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [Alias("Id")] + [object] + $User, + + [Parameter()] + [switch] + $Permanent + ) + Process { + $userId = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" + + if ($Permanent) { + $resourceUri += '?isPermanentDelete=true' + } + + if ($PSCmdlet.ShouldProcess($userId, "Remove user")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" + } + + Process { + if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Remove user group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerUserGroupMember { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup, + + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] + [Alias('UserGroupMemberId')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] + [object[]] + $UserGroupMember + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToRemove = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $UserGroupMember + function Invoke-TeamViewerRestMethodInternal { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + + function Get-MemberId { + switch ($UserGroupMember) { + { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { + $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId + return $UserGroupMember + } + Default { + if ($UserGroupMember -notmatch 'u[0-9]+') { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember + } + } + else { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember.trim('u') + } + } + return $UserGroupMember + } + } + } + } + + Process { + # when members are provided as pipeline input, each member is provided as separate statement, + # thus the members should be combined to one array in order to send a single request + if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { + if (Get-MemberId -isnot [array]) { + $membersToRemove += @(Get-MemberId) + } + else { + $membersToRemove += Get-MemberId + } + $payload = $membersToRemove -join ', ' + $body = "[$payload]" + } + + # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` + # in order to accept more members + if ($membersToRemove.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $membersToRemove = @() + } + } + + End { + # A request needs to be send if there were less than 100 members + if ($membersToRemove.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + +function Remove-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [Alias('Id')] + [object] + $UserRoleId + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$UserRoleId" + } + + Process { + if ($PSCmdlet.ShouldProcess($UserRoleId.ToString(), 'Remove User Role')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Restart-TeamViewerService { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if ($PSCmdlet.ShouldProcess('TeamViewer service')) { + switch (Get-OperatingSystem) { + 'Windows' { + Restart-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon restart + } + } + } +} + + + +function Set-TeamViewerAccount { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('DisplayName')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $Password, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $OldPassword, + + [Parameter(ParameterSetName = 'ByParameters')] + [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] + [object] + $EmailLanguage, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($Name) { + $body['name'] = $Name + } + if ($Email) { + $body['email'] = $Email + } + if ($Password) { + if (-Not $OldPassword) { + $PSCmdlet.ThrowTerminatingError( + ("Old password required when attempting to change account password." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($OldPassword) + $body['oldpassword'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($EmailLanguage) { + $body['email_language'] = $EmailLanguage | Resolve-TeamViewerLanguage + } + } + 'ByProperties' { + @('name', 'email', 'password', 'oldpassword', 'email_language') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the account." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $resourceUri = "$(Get-TeamViewerApiUri)/account" + + if ($PSCmdlet.ShouldProcess("TeamViewer account")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Set-TeamViewerAPIUri { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [Parameter(Mandatory = $false)] + [string]$NewUri, + [Parameter(Mandatory = $false)] + [bool]$Default + ) + + $config = [TeamViewerConfiguration]::GetInstance() + $PSDefaultParameterValues = @{'CmdletName:Default' = $true } + + if ($PSCmdlet.ShouldProcess('TeamViewer account')) { + if ($NewUri) { + $config.APIUri = $NewUri + Write-Output "TeamViewer API URL set to: $($config.APIUri)" + } + elseif ($Default) { + $config.APIUri = 'https://webapi.teamviewer.com/api/v1' + Write-Output "TeamViewer API URL set to: $($config.APIUri)" + } + } + +} + + + +function Set-TeamViewerDevice { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Default")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] + [Alias("DeviceId")] + [Alias("Id")] + [object] + $Device, + + [Parameter(ParameterSetName = "ChangeGroup")] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(ParameterSetName = "ChangePolicy")] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId -AllowInherit -AllowNone } )] + [Alias("PolicyId")] + [object] + $Policy, + + [Parameter()] + [Alias("Alias")] + [string] + $Name, + + [Parameter()] + [string] + $Description, + + [Parameter()] + [securestring] + $Password + ) + Begin { + $body = @{} + + if ($Name) { + $body['alias'] = $Name + } + if ($Description) { + $body['description'] = $Description + } + if ($Password) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($Group) { + $body['groupid'] = $Group | Resolve-TeamViewerGroupId + } + if ($Policy) { + $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId -AllowNone -AllowInherit + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the device." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Set-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group, + + [Parameter(ParameterSetName = 'ByParameters')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias("PolicyId")] + [object] + $Policy, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + Begin { + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + $body['name'] = $Name + if ($Policy) { + $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId + } + } + 'ByProperties' { + @('name', 'policy_id') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the group." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $groupId = $Group | Resolve-TeamViewerGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Update group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Set-TeamViewerManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Alias("Alias")] + [string] + $Name, + + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias("PolicyId")] + [object] + $Policy, + + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("ManagedGroupId")] + [object] + $ManagedGroup + ) + Begin { + $body = @{} + + if ($Name) { + $body['name'] = $Name + } + if ($Policy) { + $body['teamviewerPolicyId'] = $Policy | Resolve-TeamViewerPolicyId + } + elseif ($ManagedGroup) { + $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId + } + + if ($Policy -And $ManagedGroup) { + $PSCmdlet.ThrowTerminatingError( + ("The combination of parameters -Policy and -ManagedGroup is not allowed." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the managed device." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Set-TeamViewerManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByParameters')] + [string] + $Name, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + Begin { + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + $body['name'] = $Name + } + 'ByProperties' { + @('name') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the managed group." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Update managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Set-TeamViewerManager { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { + if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { + $PSCmdlet.ThrowTerminatingError( + ("Invalid manager object. Manager must be a group or device manager." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $_ | Resolve-TeamViewerManagerId + })] + [Alias("ManagerId")] + [Alias("Id")] + [object] + $Manager, + + [Parameter(ParameterSetName = 'Device_ByParameters')] + [Parameter(ParameterSetName = 'Device_ByProperties')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(ParameterSetName = 'Group_ByParameters')] + [Parameter(ParameterSetName = 'Group_ByProperties')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(ParameterSetName = 'Device_ByParameters')] + [Parameter(ParameterSetName = 'Group_ByParameters')] + [AllowEmptyCollection()] + [string[]] + $Permissions, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByProperties')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByProperties')] + [hashtable] + $Property + ) + Begin { + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch -Wildcard ($PSCmdlet.ParameterSetName) { + '*ByParameters' { + $body['permissions'] = @($Permissions) + } + '*ByProperties' { + @('permissions') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the manager." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $deviceId = $null + $groupId = $null + if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { + if ($Device -Or $Group) { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($Manager.DeviceId) { + $deviceId = $Manager.DeviceId + } + elseif ($Manager.GroupId) { + $groupId = $Manager.GroupId + } + } + elseif ($Device) { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + } + elseif ($Group) { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + } + else { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $managerId = $Manager | Resolve-TeamViewerManagerId + if ($deviceId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" + $processMessage = "Update managed device manager" + } + elseif ($groupId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" + $processMessage = "Update managed group manager" + } + + if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Set-TeamViewerPolicy { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('PolicyId')] + [object] + $Policy, + + [Parameter(ParameterSetName = 'ByParameters')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [object[]] + $Settings, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($Name) { + $body['name'] = $Name + } + if ($Settings) { + $body['settings'] = $Settings + } + } + 'ByProperties' { + @('name', 'settings') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the policy." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $policyId = $Policy | Resolve-TeamViewerPolicyId + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" + + if ($PSCmdlet.ShouldProcess($policyId, "Update policy")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json -Depth 25))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +$global:TeamViewerProxyUriSet = $null + +function Set-TeamViewerPSProxy { + [CmdletBinding(SupportsShouldProcess =$true)] + param ( + [Parameter(Mandatory=$true)] + [Uri] + $ProxyUri + ) + + if($PSCmdlet.ShouldProcess($ProxyUri,"Sets proxy for WebAPI")){ + $global:TeamViewerProxyUriSet = $ProxyUri + $global:TeamViewerProxyUriRemoved = $false + $global:TeamViewerProxyUriRemoved | Out-Null + + [Environment]::SetEnvironmentVariable("TeamViewerProxyUri", $ProxyUri, "User") + + Write-Output "Proxy set to $TeamViewerProxyUriSet" + } +} + + + + +function Set-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [Alias("Id")] + [object] + $User, + + [Parameter(ParameterSetName = 'ByParameters')] + [boolean] + $Active, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('DisplayName')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $Password, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $SsoCustomerIdentifier, + + [Parameter(ParameterSetName = 'ByParameters')] + [array] + $Permissions, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($PSBoundParameters.ContainsKey('Active')) { + $body['active'] = $Active + } + if ($Email) { + $body['email'] = $Email + } + if ($Name) { + $body['name'] = $Name + } + if ($Password) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($SsoCustomerIdentifier) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) + $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($Permissions) { + $body['permissions'] = $Permissions -join ',' + } + } + 'ByProperties' { + @('active', 'email', 'name', 'password', 'sso_customer_id', 'permissions') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the user." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $userId = Resolve-TeamViewerUserId -User $User + $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" + + if ($PSCmdlet.ShouldProcess($userId, "Update user profile")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Set-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup, + + [Parameter(Mandatory = $true)] + [Alias("UserGroupName")] + [string] + $Name + ) + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" + $body = @{ name = $Name } + } + Process { + if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Change user group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + } +} + + + + +function Set-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true )] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('UserRoleName')] + [string] + $Name, + + [Parameter(Mandatory = $false)] + [AllowEmptyCollection()] + [object[]] + $Permissions, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId + ) + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + $body = @{ + Name = $Name + Permissions = @() + UserRoleId = $UserRoleId + + } + if ($Permissions) { + $body.Permissions = @($Permissions) + } + } + Process { + if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = $response + Write-Output $result + } + } + +} + + + +function Start-TeamViewerService { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if ($PSCmdlet.ShouldProcess("TeamViewer service")) { + switch (Get-OperatingSystem) { + 'Windows' { + Start-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon start + } + } + } +} + + + +function Stop-TeamViewerService { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if ($PSCmdlet.ShouldProcess("TeamViewer service")) { + switch (Get-OperatingSystem) { + 'Windows' { + Stop-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon stop + } + } + } +} + + + +function Test-TeamViewerConnectivity { + param( + [Parameter()] + [switch] + $Quiet + ) + + $endpoints = @( + @{ Hostname = 'webapi.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'login.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'meeting.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'sso.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'download.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'configdl.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'get.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'go.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'client.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'feedbackservice.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'remotescriptingstorage.blob.core.windows.net'; TcpPort = 443; } + @{ Hostname = 'chatlivestorage.blob.core.windows.net'; TcpPort = 443; } + ) + 1..16 | ForEach-Object { + $endpoints += @{ Hostname = "router$_.teamviewer.com"; TcpPort = (5938, 443, 80) } + } + + $results = $endpoints | ForEach-Object { + $endpoint = $_ + $portSucceeded = $endpoint.TcpPort | Where-Object { + Write-Verbose "Checking endpoint $($endpoint.Hostname) on port $_" + Test-TcpConnection -Hostname $endpoint.Hostname -Port $_ + } | Select-Object -First 1 + $endpoint.Succeeded = [bool]$portSucceeded + $endpoint.TcpPort = if ($endpoint.Succeeded) { $portSucceeded } else { $endpoint.TcpPort } + return $endpoint + } + + if ($Quiet) { + ![bool]($results | Where-Object { -Not $_.Succeeded }) + } + else { + $results | ` + ForEach-Object { New-Object PSObject -Property $_ } | ` + Select-Object -Property Hostname, TcpPort, Succeeded | ` + Sort-Object Hostname + } +} + + + +function Test-TeamViewerInstallation { + if (Get-TeamViewerInstallationDirectory) { + return $true + } + else { + return $false + } +} + + + +function Unpublish-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(Mandatory = $true)] + [Alias("UserId")] + [object[]] + $User + ) + + $groupId = $Group | Resolve-TeamViewerGroupId + $userIds = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/unshare_group" + $body = @{users = @($userIds) } + + if ($PSCmdlet.ShouldProcess($userids, "Remove group share")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + diff --git a/docs/about_TeamViewerPS.md b/Cmdlets/about_TeamViewerPS.md similarity index 100% rename from docs/about_TeamViewerPS.md rename to Cmdlets/about_TeamViewerPS.md diff --git a/docs/Cmdlets_help/Add-TeamViewerAssignment.md b/Docs/Help/Add-TeamViewerAssignment.md similarity index 97% rename from docs/Cmdlets_help/Add-TeamViewerAssignment.md rename to Docs/Help/Add-TeamViewerAssignment.md index 873289f..c392d33 100644 --- a/docs/Cmdlets_help/Add-TeamViewerAssignment.md +++ b/Docs/Help/Add-TeamViewerAssignment.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerAssignment.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerAssignment.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerCustomization.md b/Docs/Help/Add-TeamViewerCustomization.md similarity index 98% rename from docs/Cmdlets_help/Add-TeamViewerCustomization.md rename to Docs/Help/Add-TeamViewerCustomization.md index 876c4dc..41c281c 100644 --- a/docs/Cmdlets_help/Add-TeamViewerCustomization.md +++ b/Docs/Help/Add-TeamViewerCustomization.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerCustomization.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerCustomization.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md b/Docs/Help/Add-TeamViewerManagedDevice.md similarity index 98% rename from docs/Cmdlets_help/Add-TeamViewerManagedDevice.md rename to Docs/Help/Add-TeamViewerManagedDevice.md index 6d32343..90e1aeb 100644 --- a/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md +++ b/Docs/Help/Add-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerManager.md b/Docs/Help/Add-TeamViewerManager.md similarity index 98% rename from docs/Cmdlets_help/Add-TeamViewerManager.md rename to Docs/Help/Add-TeamViewerManager.md index 2bbbeb0..fce955a 100644 --- a/docs/Cmdlets_help/Add-TeamViewerManager.md +++ b/Docs/Help/Add-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerManager.md schema: 2.0.0 --- @@ -220,7 +220,7 @@ Multiple values can be specified. device or group. `DeviceAdministration` (only for managed devices) allows the manager to change -device-specific properties, e.g. the device name. Also reqruied to add devices +device-specific properties, e.g. the device name. Also required to add devices to managed groups. `GroupAdministration` (only for managed groups) allows the manager to change diff --git a/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md b/Docs/Help/Add-TeamViewerRoleToAccount.md similarity index 98% rename from docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md rename to Docs/Help/Add-TeamViewerRoleToAccount.md index 6eaa3ef..518164a 100644 --- a/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md +++ b/Docs/Help/Add-TeamViewerRoleToAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerRoleToAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerRoleToAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md b/Docs/Help/Add-TeamViewerRoleToUserGroup.md similarity index 97% rename from docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md rename to Docs/Help/Add-TeamViewerRoleToUserGroup.md index ce3dfa6..4f7e88c 100644 --- a/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md +++ b/Docs/Help/Add-TeamViewerRoleToUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerRoleToUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerRoleToUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md b/Docs/Help/Add-TeamViewerSsoExclusion.md similarity index 95% rename from docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md rename to Docs/Help/Add-TeamViewerSsoExclusion.md index 29f9a0b..7b200ca 100644 --- a/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md +++ b/Docs/Help/Add-TeamViewerSsoExclusion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerSsoExclusion.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerSsoExclusion.md schema: 2.0.0 --- @@ -32,7 +32,7 @@ Sign-On but use their TeamViewer account password instead. PS /> Add-TeamViewerSsoExclusion -DomainId '45e0d050-15e6-4fcb-91b2-ea4f20fe2085' -Email 'user@example.test' ``` -Adds the email address 'user@example.test' to the exclusion list of the given +Adds the email address '' to the exclusion list of the given domain. ## PARAMETERS diff --git a/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md b/Docs/Help/Add-TeamViewerUserGroupMember.md similarity index 98% rename from docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md rename to Docs/Help/Add-TeamViewerUserGroupMember.md index 227136f..461f6b0 100644 --- a/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md +++ b/Docs/Help/Add-TeamViewerUserGroupMember.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Add-TeamViewerUserGroupMember.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserGroupMember.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Connect-TeamViewerApi.md b/Docs/Help/Connect-TeamViewerApi.md similarity index 96% rename from docs/Cmdlets_help/Connect-TeamViewerApi.md rename to Docs/Help/Connect-TeamViewerApi.md index 015a8be..ec5208e 100644 --- a/docs/Cmdlets_help/Connect-TeamViewerApi.md +++ b/Docs/Help/Connect-TeamViewerApi.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Connect-TeamViewerApi.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Connect-TeamViewerApi.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Disconnect-TeamViewerApi.md b/Docs/Help/Disconnect-TeamViewerApi.md similarity index 95% rename from docs/Cmdlets_help/Disconnect-TeamViewerApi.md rename to Docs/Help/Disconnect-TeamViewerApi.md index 6c5f1e6..e8d08a1 100644 --- a/docs/Cmdlets_help/Disconnect-TeamViewerApi.md +++ b/Docs/Help/Disconnect-TeamViewerApi.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Disconnect-TeamViewerApi.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Disconnect-TeamViewerApi.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md b/Docs/Help/Export-TeamViewerSystemInformation.md similarity index 96% rename from docs/Cmdlets_help/Export-TeamViewerSystemInformation.md rename to Docs/Help/Export-TeamViewerSystemInformation.md index 1eacf6e..7129f7f 100644 --- a/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md +++ b/Docs/Help/Export-TeamViewerSystemInformation.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Export-TeamViewerSystemInformation.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Export-TeamViewerSystemInformation.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerAccount.md b/Docs/Help/Get-TeamViewerAccount.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerAccount.md rename to Docs/Help/Get-TeamViewerAccount.md index 2052426..e421e0c 100644 --- a/docs/Cmdlets_help/Get-TeamViewerAccount.md +++ b/Docs/Help/Get-TeamViewerAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md b/Docs/Help/Get-TeamViewerConnectionReport.md similarity index 99% rename from docs/Cmdlets_help/Get-TeamViewerConnectionReport.md rename to Docs/Help/Get-TeamViewerConnectionReport.md index 6e5923f..c0f7ac6 100644 --- a/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md +++ b/Docs/Help/Get-TeamViewerConnectionReport.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerConnectionReport.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerConnectionReport.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerContact.md b/Docs/Help/Get-TeamViewerContact.md similarity index 98% rename from docs/Cmdlets_help/Get-TeamViewerContact.md rename to Docs/Help/Get-TeamViewerContact.md index 233ca74..ef6c2fe 100644 --- a/docs/Cmdlets_help/Get-TeamViewerContact.md +++ b/Docs/Help/Get-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md b/Docs/Help/Get-TeamViewerCustomModuleId.md similarity index 92% rename from docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md rename to Docs/Help/Get-TeamViewerCustomModuleId.md index efe5c9e..a03278f 100644 --- a/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md +++ b/Docs/Help/Get-TeamViewerCustomModuleId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerCustomModuleId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerCustomModuleId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerDevice.md b/Docs/Help/Get-TeamViewerDevice.md similarity index 98% rename from docs/Cmdlets_help/Get-TeamViewerDevice.md rename to Docs/Help/Get-TeamViewerDevice.md index cf40053..052b7aa 100644 --- a/docs/Cmdlets_help/Get-TeamViewerDevice.md +++ b/Docs/Help/Get-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerEventLog.md b/Docs/Help/Get-TeamViewerEventLog.md similarity index 99% rename from docs/Cmdlets_help/Get-TeamViewerEventLog.md rename to Docs/Help/Get-TeamViewerEventLog.md index 072a2fd..ff499a5 100644 --- a/docs/Cmdlets_help/Get-TeamViewerEventLog.md +++ b/Docs/Help/Get-TeamViewerEventLog.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerEventLog.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerEventLog.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerGroup.md b/Docs/Help/Get-TeamViewerGroup.md similarity index 98% rename from docs/Cmdlets_help/Get-TeamViewerGroup.md rename to Docs/Help/Get-TeamViewerGroup.md index 1f248a9..4e714e1 100644 --- a/docs/Cmdlets_help/Get-TeamViewerGroup.md +++ b/Docs/Help/Get-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerId.md b/Docs/Help/Get-TeamViewerId.md similarity index 95% rename from docs/Cmdlets_help/Get-TeamViewerId.md rename to Docs/Help/Get-TeamViewerId.md index 912b0f5..0f95950 100644 --- a/docs/Cmdlets_help/Get-TeamViewerId.md +++ b/Docs/Help/Get-TeamViewerId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md b/Docs/Help/Get-TeamViewerInstallationDirectory.md similarity index 91% rename from docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md rename to Docs/Help/Get-TeamViewerInstallationDirectory.md index 4ada3b1..785e488 100644 --- a/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md +++ b/Docs/Help/Get-TeamViewerInstallationDirectory.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerInstallationDirectory.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerInstallationDirectory.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md b/Docs/Help/Get-TeamViewerLogFilePath.md similarity index 95% rename from docs/Cmdlets_help/Get-TeamViewerLogFilePath.md rename to Docs/Help/Get-TeamViewerLogFilePath.md index 33396a8..54b0938 100644 --- a/docs/Cmdlets_help/Get-TeamViewerLogFilePath.md +++ b/Docs/Help/Get-TeamViewerLogFilePath.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerLogFilePath +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerLogFilePath schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md b/Docs/Help/Get-TeamViewerManagedDevice.md similarity index 98% rename from docs/Cmdlets_help/Get-TeamViewerManagedDevice.md rename to Docs/Help/Get-TeamViewerManagedDevice.md index d214115..a3945e3 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md +++ b/Docs/Help/Get-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md b/Docs/Help/Get-TeamViewerManagedGroup.md similarity index 97% rename from docs/Cmdlets_help/Get-TeamViewerManagedGroup.md rename to Docs/Help/Get-TeamViewerManagedGroup.md index c4d44b3..06d3002 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md +++ b/Docs/Help/Get-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManagementId.md b/Docs/Help/Get-TeamViewerManagementId.md similarity index 94% rename from docs/Cmdlets_help/Get-TeamViewerManagementId.md rename to Docs/Help/Get-TeamViewerManagementId.md index f7629be..aa331fe 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManagementId.md +++ b/Docs/Help/Get-TeamViewerManagementId.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManagementId.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerManagementId.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerManager.md b/Docs/Help/Get-TeamViewerManager.md similarity index 97% rename from docs/Cmdlets_help/Get-TeamViewerManager.md rename to Docs/Help/Get-TeamViewerManager.md index 2f608fa..831373e 100644 --- a/docs/Cmdlets_help/Get-TeamViewerManager.md +++ b/Docs/Help/Get-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerPolicy.md b/Docs/Help/Get-TeamViewerPolicy.md similarity index 97% rename from docs/Cmdlets_help/Get-TeamViewerPolicy.md rename to Docs/Help/Get-TeamViewerPolicy.md index 143b190..eafc5e6 100644 --- a/docs/Cmdlets_help/Get-TeamViewerPolicy.md +++ b/Docs/Help/Get-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md b/Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md rename to Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md index 47d8ec0..cc9b3bc 100644 --- a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md +++ b/Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md b/Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md rename to Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md index abc39fc..d96ae56 100644 --- a/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md +++ b/Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerRoleAssignmentToUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerService.md b/Docs/Help/Get-TeamViewerService.md similarity index 95% rename from docs/Cmdlets_help/Get-TeamViewerService.md rename to Docs/Help/Get-TeamViewerService.md index 3d9ae9a..f9a73f4 100644 --- a/docs/Cmdlets_help/Get-TeamViewerService.md +++ b/Docs/Help/Get-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md b/Docs/Help/Get-TeamViewerSsoDomain.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerSsoDomain.md rename to Docs/Help/Get-TeamViewerSsoDomain.md index 5a5f4f5..0deee91 100644 --- a/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md +++ b/Docs/Help/Get-TeamViewerSsoDomain.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerSsoDomain.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerSsoDomain.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md b/Docs/Help/Get-TeamViewerSsoExclusion.md similarity index 97% rename from docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md rename to Docs/Help/Get-TeamViewerSsoExclusion.md index cc841ca..3faeb36 100644 --- a/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md +++ b/Docs/Help/Get-TeamViewerSsoExclusion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerSsoExclusion.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerSsoExclusion.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUser.md b/Docs/Help/Get-TeamViewerUser.md similarity index 98% rename from docs/Cmdlets_help/Get-TeamViewerUser.md rename to Docs/Help/Get-TeamViewerUser.md index c20a735..085e128 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUser.md +++ b/Docs/Help/Get-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUserGroup.md b/Docs/Help/Get-TeamViewerUserGroup.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerUserGroup.md rename to Docs/Help/Get-TeamViewerUserGroup.md index fb81750..d0f4478 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUserGroup.md +++ b/Docs/Help/Get-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-Get-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-Get-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md b/Docs/Help/Get-TeamViewerUserGroupMember.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md rename to Docs/Help/Get-TeamViewerUserGroupMember.md index c3e2334..f2bf029 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md +++ b/Docs/Help/Get-TeamViewerUserGroupMember.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerUserGroupMember.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerUserGroupMember.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerUserRole.md b/Docs/Help/Get-TeamViewerUserRole.md similarity index 96% rename from docs/Cmdlets_help/Get-TeamViewerUserRole.md rename to Docs/Help/Get-TeamViewerUserRole.md index 1fcf81a..036d199 100644 --- a/docs/Cmdlets_help/Get-TeamViewerUserRole.md +++ b/Docs/Help/Get-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Get-TeamViewerVersion.md b/Docs/Help/Get-TeamViewerVersion.md similarity index 95% rename from docs/Cmdlets_help/Get-TeamViewerVersion.md rename to Docs/Help/Get-TeamViewerVersion.md index 9302e8a..7204fed 100644 --- a/docs/Cmdlets_help/Get-TeamViewerVersion.md +++ b/Docs/Help/Get-TeamViewerVersion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Get-TeamViewerVersion.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerVersion.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md b/Docs/Help/Invoke-TeamViewerPackageDownload.md similarity index 97% rename from docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md rename to Docs/Help/Invoke-TeamViewerPackageDownload.md index 51fa4ea..4a2e10e 100644 --- a/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md +++ b/Docs/Help/Invoke-TeamViewerPackageDownload.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Invoke-TeamViewerPackageDownload.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Invoke-TeamViewerPackageDownload.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Invoke-TeamViewerPing.md b/Docs/Help/Invoke-TeamViewerPing.md similarity index 96% rename from docs/Cmdlets_help/Invoke-TeamViewerPing.md rename to Docs/Help/Invoke-TeamViewerPing.md index 39f793d..a7d0ed9 100644 --- a/docs/Cmdlets_help/Invoke-TeamViewerPing.md +++ b/Docs/Help/Invoke-TeamViewerPing.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Invoke-TeamViewerPing.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Invoke-TeamViewerPing.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerContact.md b/Docs/Help/New-TeamViewerContact.md similarity index 98% rename from docs/Cmdlets_help/New-TeamViewerContact.md rename to Docs/Help/New-TeamViewerContact.md index a4a4f97..c11bd1e 100644 --- a/docs/Cmdlets_help/New-TeamViewerContact.md +++ b/Docs/Help/New-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerDevice.md b/Docs/Help/New-TeamViewerDevice.md similarity index 98% rename from docs/Cmdlets_help/New-TeamViewerDevice.md rename to Docs/Help/New-TeamViewerDevice.md index 9527489..a5dc743 100644 --- a/docs/Cmdlets_help/New-TeamViewerDevice.md +++ b/Docs/Help/New-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerGroup.md b/Docs/Help/New-TeamViewerGroup.md similarity index 98% rename from docs/Cmdlets_help/New-TeamViewerGroup.md rename to Docs/Help/New-TeamViewerGroup.md index f58eccd..211c6c1 100644 --- a/docs/Cmdlets_help/New-TeamViewerGroup.md +++ b/Docs/Help/New-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerManagedGroup.md b/Docs/Help/New-TeamViewerManagedGroup.md similarity index 97% rename from docs/Cmdlets_help/New-TeamViewerManagedGroup.md rename to Docs/Help/New-TeamViewerManagedGroup.md index ad96a8f..8b776b3 100644 --- a/docs/Cmdlets_help/New-TeamViewerManagedGroup.md +++ b/Docs/Help/New-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerPolicy.md b/Docs/Help/New-TeamViewerPolicy.md similarity index 98% rename from docs/Cmdlets_help/New-TeamViewerPolicy.md rename to Docs/Help/New-TeamViewerPolicy.md index 36c2e21..987ba0b 100644 --- a/docs/Cmdlets_help/New-TeamViewerPolicy.md +++ b/Docs/Help/New-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerUser.md b/Docs/Help/New-TeamViewerUser.md similarity index 99% rename from docs/Cmdlets_help/New-TeamViewerUser.md rename to Docs/Help/New-TeamViewerUser.md index 59193f1..7d512da 100644 --- a/docs/Cmdlets_help/New-TeamViewerUser.md +++ b/Docs/Help/New-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerUserGroup.md b/Docs/Help/New-TeamViewerUserGroup.md similarity index 97% rename from docs/Cmdlets_help/New-TeamViewerUserGroup.md rename to Docs/Help/New-TeamViewerUserGroup.md index a316b33..77e3431 100644 --- a/docs/Cmdlets_help/New-TeamViewerUserGroup.md +++ b/Docs/Help/New-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/New-TeamViewerUserRole.md b/Docs/Help/New-TeamViewerUserRole.md similarity index 98% rename from docs/Cmdlets_help/New-TeamViewerUserRole.md rename to Docs/Help/New-TeamViewerUserRole.md index f6deb32..766ebe1 100644 --- a/docs/Cmdlets_help/New-TeamViewerUserRole.md +++ b/Docs/Help/New-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/New-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Publish-TeamViewerGroup.md b/Docs/Help/Publish-TeamViewerGroup.md similarity index 98% rename from docs/Cmdlets_help/Publish-TeamViewerGroup.md rename to Docs/Help/Publish-TeamViewerGroup.md index db62dec..d055ab9 100644 --- a/docs/Cmdlets_help/Publish-TeamViewerGroup.md +++ b/Docs/Help/Publish-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Publish-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Publish-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerAssignment.md b/Docs/Help/Remove-TeamViewerAssignment.md similarity index 91% rename from docs/Cmdlets_help/Remove-TeamViewerAssignment.md rename to Docs/Help/Remove-TeamViewerAssignment.md index 5635c9a..ce7a5c8 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerAssignment.md +++ b/Docs/Help/Remove-TeamViewerAssignment.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerAssignment.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerAssignment.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerContact.md b/Docs/Help/Remove-TeamViewerContact.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerContact.md rename to Docs/Help/Remove-TeamViewerContact.md index f9a6981..40d3219 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerContact.md +++ b/Docs/Help/Remove-TeamViewerContact.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerContact.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerContact.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerCustomization.md b/Docs/Help/Remove-TeamViewerCustomization.md similarity index 92% rename from docs/Cmdlets_help/Remove-TeamViewerCustomization.md rename to Docs/Help/Remove-TeamViewerCustomization.md index d42f16c..61778f4 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerCustomization.md +++ b/Docs/Help/Remove-TeamViewerCustomization.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerCustomization.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerCustomization.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerDevice.md b/Docs/Help/Remove-TeamViewerDevice.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerDevice.md rename to Docs/Help/Remove-TeamViewerDevice.md index 5cb101e..8ce6b1a 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerDevice.md +++ b/Docs/Help/Remove-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerGroup.md b/Docs/Help/Remove-TeamViewerGroup.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerGroup.md rename to Docs/Help/Remove-TeamViewerGroup.md index c1aa0b2..2a3906a 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerGroup.md +++ b/Docs/Help/Remove-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md b/Docs/Help/Remove-TeamViewerManagedDevice.md similarity index 98% rename from docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md rename to Docs/Help/Remove-TeamViewerManagedDevice.md index d205174..4045cb1 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md +++ b/Docs/Help/Remove-TeamViewerManagedDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManagedDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerManagedDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md b/Docs/Help/Remove-TeamViewerManagedDeviceManagement.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md rename to Docs/Help/Remove-TeamViewerManagedDeviceManagement.md index ebfdf98..7230a0a 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md +++ b/Docs/Help/Remove-TeamViewerManagedDeviceManagement.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManagedDeviceManagement.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerManagedDeviceManagement.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md b/Docs/Help/Remove-TeamViewerManagedGroup.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md rename to Docs/Help/Remove-TeamViewerManagedGroup.md index 75be21e..8ba7a95 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md +++ b/Docs/Help/Remove-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerManager.md b/Docs/Help/Remove-TeamViewerManager.md similarity index 98% rename from docs/Cmdlets_help/Remove-TeamViewerManager.md rename to Docs/Help/Remove-TeamViewerManager.md index 996e3b5..8cbece9 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerManager.md +++ b/Docs/Help/Remove-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md b/Docs/Help/Remove-TeamViewerPSProxy.md similarity index 92% rename from docs/Cmdlets_help/Remove-TeamViewerPSProxy.md rename to Docs/Help/Remove-TeamViewerPSProxy.md index c4c3200..b0c243a 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerPSProxy.md +++ b/Docs/Help/Remove-TeamViewerPSProxy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerPSProxy +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerPSProxy schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerPolicy.md b/Docs/Help/Remove-TeamViewerPolicy.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerPolicy.md rename to Docs/Help/Remove-TeamViewerPolicy.md index 26ed60f..85d7e6f 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerPolicy.md +++ b/Docs/Help/Remove-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerPolicyFromManagedDevice.md b/Docs/Help/Remove-TeamViewerPolicyFromManagedDevice.md similarity index 100% rename from docs/Cmdlets_help/Remove-TeamViewerPolicyFromManagedDevice.md rename to Docs/Help/Remove-TeamViewerPolicyFromManagedDevice.md diff --git a/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md b/Docs/Help/Remove-TeamViewerRoleFromAccount.md similarity index 98% rename from docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md rename to Docs/Help/Remove-TeamViewerRoleFromAccount.md index cc8dc6b..1856e45 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md +++ b/Docs/Help/Remove-TeamViewerRoleFromAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerRoleFromAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerRoleFromAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md b/Docs/Help/Remove-TeamViewerRoleFromUserGroup.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md rename to Docs/Help/Remove-TeamViewerRoleFromUserGroup.md index e88378b..685dc3c 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md +++ b/Docs/Help/Remove-TeamViewerRoleFromUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerRoleFromUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerRoleFromUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md b/Docs/Help/Remove-TeamViewerSsoExclusion.md similarity index 95% rename from docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md rename to Docs/Help/Remove-TeamViewerSsoExclusion.md index 63cc616..ad61ad7 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md +++ b/Docs/Help/Remove-TeamViewerSsoExclusion.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerSsoExclusion.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerSsoExclusion.md schema: 2.0.0 --- @@ -32,7 +32,7 @@ Sign-On but use their TeamViewer account password instead. PS /> Remove-TeamViewerSsoExclusion -DomainId '45e0d050-15e6-4fcb-91b2-ea4f20fe2085' -Email 'user@example.test' ``` -Removes the email address 'user@example.test' from the exclusion list of the +Removes the email address '' from the exclusion list of the given domain. ## PARAMETERS diff --git a/docs/Cmdlets_help/Remove-TeamViewerUser.md b/Docs/Help/Remove-TeamViewerUser.md similarity index 98% rename from docs/Cmdlets_help/Remove-TeamViewerUser.md rename to Docs/Help/Remove-TeamViewerUser.md index 3fc0094..00ff8d8 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUser.md +++ b/Docs/Help/Remove-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUser.md schema: 2.0.0 --- @@ -31,7 +31,6 @@ If the switch -Permanent is added the user is delete from TeamViewer completely, PS C:\> Remove-TeamViewerUser -User 'u1234' ``` - ## PARAMETERS ### -ApiToken diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md b/Docs/Help/Remove-TeamViewerUserGroup.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerUserGroup.md rename to Docs/Help/Remove-TeamViewerUserGroup.md index a78d4fd..f95ab38 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md +++ b/Docs/Help/Remove-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md b/Docs/Help/Remove-TeamViewerUserGroupMember.md similarity index 98% rename from docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md rename to Docs/Help/Remove-TeamViewerUserGroupMember.md index 281e950..212ce04 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md +++ b/Docs/Help/Remove-TeamViewerUserGroupMember.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUserGroupMember.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroupMember.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Remove-TeamViewerUserRole.md b/Docs/Help/Remove-TeamViewerUserRole.md similarity index 97% rename from docs/Cmdlets_help/Remove-TeamViewerUserRole.md rename to Docs/Help/Remove-TeamViewerUserRole.md index e2b0c13..ba83a1a 100644 --- a/docs/Cmdlets_help/Remove-TeamViewerUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Remove-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Restart-TeamViewerService.md b/Docs/Help/Restart-TeamViewerService.md similarity index 96% rename from docs/Cmdlets_help/Restart-TeamViewerService.md rename to Docs/Help/Restart-TeamViewerService.md index f354e28..85a2483 100644 --- a/docs/Cmdlets_help/Restart-TeamViewerService.md +++ b/Docs/Help/Restart-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Restart-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Restart-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerAccount.md b/Docs/Help/Set-TeamViewerAccount.md similarity index 98% rename from docs/Cmdlets_help/Set-TeamViewerAccount.md rename to Docs/Help/Set-TeamViewerAccount.md index aefa72a..18ce4fe 100644 --- a/docs/Cmdlets_help/Set-TeamViewerAccount.md +++ b/Docs/Help/Set-TeamViewerAccount.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerAccount.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerDevice.md b/Docs/Help/Set-TeamViewerDevice.md similarity index 99% rename from docs/Cmdlets_help/Set-TeamViewerDevice.md rename to Docs/Help/Set-TeamViewerDevice.md index d6e77ca..780379e 100644 --- a/docs/Cmdlets_help/Set-TeamViewerDevice.md +++ b/Docs/Help/Set-TeamViewerDevice.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerDevice.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerDevice.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerGroup.md b/Docs/Help/Set-TeamViewerGroup.md similarity index 98% rename from docs/Cmdlets_help/Set-TeamViewerGroup.md rename to Docs/Help/Set-TeamViewerGroup.md index c9c8e45..f777eeb 100644 --- a/docs/Cmdlets_help/Set-TeamViewerGroup.md +++ b/Docs/Help/Set-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerManagedDevice.md b/Docs/Help/Set-TeamViewerManagedDevice.md similarity index 100% rename from docs/Cmdlets_help/Set-TeamViewerManagedDevice.md rename to Docs/Help/Set-TeamViewerManagedDevice.md diff --git a/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md b/Docs/Help/Set-TeamViewerManagedGroup.md similarity index 98% rename from docs/Cmdlets_help/Set-TeamViewerManagedGroup.md rename to Docs/Help/Set-TeamViewerManagedGroup.md index 21d6bd4..2902456 100644 --- a/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md +++ b/Docs/Help/Set-TeamViewerManagedGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerManagedGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerManagedGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerManager.md b/Docs/Help/Set-TeamViewerManager.md similarity index 99% rename from docs/Cmdlets_help/Set-TeamViewerManager.md rename to Docs/Help/Set-TeamViewerManager.md index 4914428..bf45e9a 100644 --- a/docs/Cmdlets_help/Set-TeamViewerManager.md +++ b/Docs/Help/Set-TeamViewerManager.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerManager.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerManager.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerPSProxy.md b/Docs/Help/Set-TeamViewerPSProxy.md similarity index 95% rename from docs/Cmdlets_help/Set-TeamViewerPSProxy.md rename to Docs/Help/Set-TeamViewerPSProxy.md index fedd0cb..0bc462d 100644 --- a/docs/Cmdlets_help/Set-TeamViewerPSProxy.md +++ b/Docs/Help/Set-TeamViewerPSProxy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerPSProxy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerPSProxy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerPolicy.md b/Docs/Help/Set-TeamViewerPolicy.md similarity index 98% rename from docs/Cmdlets_help/Set-TeamViewerPolicy.md rename to Docs/Help/Set-TeamViewerPolicy.md index 2d0915f..29091e1 100644 --- a/docs/Cmdlets_help/Set-TeamViewerPolicy.md +++ b/Docs/Help/Set-TeamViewerPolicy.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerPolicy.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerPolicy.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerUser.md b/Docs/Help/Set-TeamViewerUser.md similarity index 99% rename from docs/Cmdlets_help/Set-TeamViewerUser.md rename to Docs/Help/Set-TeamViewerUser.md index 8b49745..6fd6ae6 100644 --- a/docs/Cmdlets_help/Set-TeamViewerUser.md +++ b/Docs/Help/Set-TeamViewerUser.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerUser.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerUser.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerUserGroup.md b/Docs/Help/Set-TeamViewerUserGroup.md similarity index 97% rename from docs/Cmdlets_help/Set-TeamViewerUserGroup.md rename to Docs/Help/Set-TeamViewerUserGroup.md index bc9b69d..499bf21 100644 --- a/docs/Cmdlets_help/Set-TeamViewerUserGroup.md +++ b/Docs/Help/Set-TeamViewerUserGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerUserGroup.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Set-TeamViewerUserRole.md b/Docs/Help/Set-TeamViewerUserRole.md similarity index 98% rename from docs/Cmdlets_help/Set-TeamViewerUserRole.md rename to Docs/Help/Set-TeamViewerUserRole.md index 95ff406..d54e14c 100644 --- a/docs/Cmdlets_help/Set-TeamViewerUserRole.md +++ b/Docs/Help/Set-TeamViewerUserRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Set-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerUserRole.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Start-TeamViewerService.md b/Docs/Help/Start-TeamViewerService.md similarity index 96% rename from docs/Cmdlets_help/Start-TeamViewerService.md rename to Docs/Help/Start-TeamViewerService.md index c672810..a1ed8ec 100644 --- a/docs/Cmdlets_help/Start-TeamViewerService.md +++ b/Docs/Help/Start-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Start-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Start-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Stop-TeamViewerService.md b/Docs/Help/Stop-TeamViewerService.md similarity index 96% rename from docs/Cmdlets_help/Stop-TeamViewerService.md rename to Docs/Help/Stop-TeamViewerService.md index 26a8f0b..cacd47b 100644 --- a/docs/Cmdlets_help/Stop-TeamViewerService.md +++ b/Docs/Help/Stop-TeamViewerService.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Stop-TeamViewerService.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Stop-TeamViewerService.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Test-TeamViewerConnectivity.md b/Docs/Help/Test-TeamViewerConnectivity.md similarity index 96% rename from docs/Cmdlets_help/Test-TeamViewerConnectivity.md rename to Docs/Help/Test-TeamViewerConnectivity.md index 5e5e4b0..b1b20be 100644 --- a/docs/Cmdlets_help/Test-TeamViewerConnectivity.md +++ b/Docs/Help/Test-TeamViewerConnectivity.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Test-TeamViewerConnectivity.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Test-TeamViewerConnectivity.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Test-TeamViewerInstallation.md b/Docs/Help/Test-TeamViewerInstallation.md similarity index 94% rename from docs/Cmdlets_help/Test-TeamViewerInstallation.md rename to Docs/Help/Test-TeamViewerInstallation.md index 3b36d7f..548d498 100644 --- a/docs/Cmdlets_help/Test-TeamViewerInstallation.md +++ b/Docs/Help/Test-TeamViewerInstallation.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Test-TeamViewerInstallation.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Test-TeamViewerInstallation.md schema: 2.0.0 --- diff --git a/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md b/Docs/Help/Unpublish-TeamViewerGroup.md similarity index 97% rename from docs/Cmdlets_help/Unpublish-TeamViewerGroup.md rename to Docs/Help/Unpublish-TeamViewerGroup.md index 887e2ab..33975ae 100644 --- a/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md +++ b/Docs/Help/Unpublish-TeamViewerGroup.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/docs/Cmdlets_help/Unpublish-TeamViewerGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Unpublish-TeamViewerGroup.md schema: 2.0.0 --- diff --git a/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 b/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 index 83c150b..fe7a981 100644 --- a/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerAssignment.Tests.ps1 @@ -1,9 +1,9 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerAssignment.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerVersion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerAssignment.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerVersion.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } Describe 'Add-TeamViewerAssignment' { diff --git a/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 b/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 index ce9e1e5..9f1dca5 100644 --- a/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerCustomization.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerCustomization.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerCustomization.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } diff --git a/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 index e4997a2..34b4762 100644 --- a/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerManager.Tests.ps1 b/Tests/Public/Add-TeamViewerManager.Tests.ps1 index dd605dc..39af1e1 100644 --- a/Tests/Public/Add-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerManager.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 index ab247ef..9d42545 100644 --- a/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerRoleToAccount.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index d6ca0ac..4ebe068 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerRoleToUserGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 b/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 index 2c4842f..d67f711 100644 --- a/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerSsoExclusion.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerSsoExclusion.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerSsoExclusion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 index 571fb6e..2e3542c 100644 --- a/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupMember.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Add-TeamViewerUserGroupMember.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserGroupMember.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Connect-TeamViewerApi.Tests.ps1 b/Tests/Public/Connect-TeamViewerApi.Tests.ps1 index 3d42fb5..cb42465 100644 --- a/Tests/Public/Connect-TeamViewerApi.Tests.ps1 +++ b/Tests/Public/Connect-TeamViewerApi.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Connect-TeamViewerApi.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Invoke-TeamViewerPing.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Connect-TeamViewerApi.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 b/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 index 494b067..0c40b4b 100644 --- a/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 +++ b/Tests/Public/Disconnect-TeamViewerApi.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Disconnect-TeamViewerApi.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Disconnect-TeamViewerApi.ps1" } Describe 'Disconnect-TeamViewerApi' { diff --git a/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 b/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 index 58610ba..ab5dbab 100644 --- a/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 +++ b/Tests/Public/Export-TeamViewerSystemInformation.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Export-TeamViewerSystemInformation.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Export-TeamViewerSystemInformation.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock -CommandName Test-TeamViewerInstallation { return $true } Mock -CommandName Get-OperatingSystem { return 'Windows' } diff --git a/Tests/Public/Get-TeamViewerAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerAccount.Tests.ps1 index 395b6ce..0480b42 100644 --- a/Tests/Public/Get-TeamViewerAccount.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerAccount.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerAccount.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 b/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 index 62aad8b..1001943 100644 --- a/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerConnectionReport.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../Docs/TeamViewerPS.Types.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerConnectionReport.ps1" + . "$PSScriptRoot\..\..\Cmdlets\TeamViewerPS.Types.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerConnectionReport.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} @@ -227,4 +227,4 @@ Describe 'Get-TeamViewerConnectionReport' { $body.to_date | Should -BeNullOrEmpty } } -} +} \ No newline at end of file diff --git a/Tests/Public/Get-TeamViewerContact.Tests.ps1 b/Tests/Public/Get-TeamViewerContact.Tests.ps1 index e65a62c..b1ffc82 100644 --- a/Tests/Public/Get-TeamViewerContact.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerContact.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerContact.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerContact.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 b/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 index 2ebd483..9efc7a2 100644 --- a/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerCustomModuleId.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerCustomModuleId.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerCustomModuleId.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } diff --git a/Tests/Public/Get-TeamViewerDevice.Tests.ps1 b/Tests/Public/Get-TeamViewerDevice.Tests.ps1 index eea87a7..25b4ad7 100644 --- a/Tests/Public/Get-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 b/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 index e0b8615..f3c1440 100644 --- a/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerEventLog.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerEventLog.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerEventLog.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerGroup.Tests.ps1 index e439a46..ef40711 100644 --- a/Tests/Public/Get-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerId.Tests.ps1 b/Tests/Public/Get-TeamViewerId.Tests.ps1 index 519c360..348e7de 100644 --- a/Tests/Public/Get-TeamViewerId.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerId.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerId.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerId.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-ItemPropertyValue { 123456 } } diff --git a/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 b/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 index b684fb2..4877c64 100644 --- a/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerInstallationDirectory.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } diff --git a/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 b/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 index 191c45b..40383a4 100644 --- a/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerLogFilePath.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerLogFilePath.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerLogFilePath.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-TSCSearchDirectory { diff --git a/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 index 1058365..cf20d9b 100644 --- a/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 index 09ee3ad..4fbf6df 100644 --- a/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 b/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 index 97d250c..4c40770 100644 --- a/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManagementId.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManagementId.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerManagementId.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testManagementId = New-Guid $null = $testManagementId @@ -11,11 +11,12 @@ BeforeAll { Describe 'Get-TeamViewerManagementId' { Context 'Windows' { BeforeAll { - function Get-TestItemValue([object]$obj) {} + function Get-TestItemValue([object]$obj) { + } Mock Get-TestItemValue ` -ParameterFilter { $obj -eq 'Unmanaged' } { } Mock Get-TestItemValue ` - -ParameterFilter { $obj -eq 'ManagementId' } { $testManagementId.ToString("B") } + -ParameterFilter { $obj -eq 'ManagementId' } { $testManagementId.ToString('B') } $testItem = [PSCustomObject]@{} $testItem | Add-Member ` -MemberType ScriptMethod ` @@ -77,7 +78,7 @@ Describe 'Get-TeamViewerManagementId' { -MockWith { } Mock Get-TeamViewerLinuxGlobalConfig ` -ParameterFilter { $Name -eq 'DeviceManagementV2\ManagementId' } ` - -MockWith { $testManagementId.ToString("B") } + -MockWith { $testManagementId.ToString('B') } } It 'Should return the Management ID from the global configuration' { diff --git a/Tests/Public/Get-TeamViewerManager.Tests.ps1 b/Tests/Public/Get-TeamViewerManager.Tests.ps1 index 69a3226..0860e72 100644 --- a/Tests/Public/Get-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerManager.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 b/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 index 61bca1b..50be3d8 100644 --- a/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerPolicy.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 index 8622899..7a330ff 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerRoleAssignmentToAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-TeamViewerApiUri { '//unit.test' } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 index e13febb..94593b9 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerRoleAssignmentToUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-TeamViewerApiUri { '//unit.test' } diff --git a/Tests/Public/Get-TeamViewerService.Tests.ps1 b/Tests/Public/Get-TeamViewerService.Tests.ps1 index 1ab2467..943c0f6 100644 --- a/Tests/Public/Get-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerService.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Get-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 b/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 index 18509fe..a74540c 100644 --- a/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerSsoDomain.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerSsoDomain.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerSsoDomain.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 b/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 index 778c89d..610606d 100644 --- a/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerSsoExclusion.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerSsoExclusion.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerSsoExclusion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUser.Tests.ps1 b/Tests/Public/Get-TeamViewerUser.Tests.ps1 index 03aace6..b25503e 100644 --- a/Tests/Public/Get-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUser.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 index ac34349..3a9ebad 100644 --- a/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} @@ -32,8 +32,8 @@ Describe 'Get-TeamViewerUserGroup' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq '//unit.test/usergroups' -And ` - $Method -eq 'Get' } + $Uri -eq '//unit.test/usergroups' -And ` + $Method -eq 'Get' } } It 'Should return UserGroup objects' { @@ -71,8 +71,8 @@ Describe 'Get-TeamViewerUserGroup' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId" -And ` - $Method -eq 'Get' } + $Uri -eq "//unit.test/usergroups/$testUserGroupId" -And ` + $Method -eq 'Get' } } It 'Should handle domain object as input' { @@ -81,8 +81,8 @@ Describe 'Get-TeamViewerUserGroup' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/usergroups/$testUserGroupId" -And ` - $Method -eq 'Get' } + $Uri -eq "//unit.test/usergroups/$testUserGroupId" -And ` + $Method -eq 'Get' } } It 'Should return a UserGroup object' { diff --git a/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 index 622e8d3..a0314c6 100644 --- a/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserGroupMember.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUserGroupMember.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUserGroupMember.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 index 39979ce..4dc84ce 100644 --- a/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUserRole.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Get-TeamViewerVersion.Tests.ps1 b/Tests/Public/Get-TeamViewerVersion.Tests.ps1 index add13b3..09b3860 100644 --- a/Tests/Public/Get-TeamViewerVersion.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerVersion.Tests.ps1 @@ -1,14 +1,14 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerVersion.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerVersion.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock Get-ItemPropertyValue { '15.10.0' } } -Describe "Get-TeamViewerVersion" { +Describe 'Get-TeamViewerVersion' { Context 'Windows' { BeforeAll { Mock Get-TeamViewerRegKeyPath { 'testRegistry' } @@ -16,7 +16,7 @@ Describe "Get-TeamViewerVersion" { Mock Test-TeamViewerInstallation { $true } } - It "Should return the TeamViewer Version from the Windows Registry" { + It 'Should return the TeamViewer Version from the Windows Registry' { Get-TeamViewerVersion | Should -Be '15.10.0' Assert-MockCalled Get-ItemPropertyValue -Scope It -Times 1 -ParameterFilter { $Path -Eq 'testRegistry' -And $Name -Eq 'Version' diff --git a/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 b/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 index be7ad54..8520ca1 100644 --- a/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 +++ b/Tests/Public/Invoke-TeamViewerPing.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Invoke-TeamViewerPing.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Invoke-TeamViewerPing.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerContact.Tests.ps1 b/Tests/Public/New-TeamViewerContact.Tests.ps1 index 92de509..e4e836a 100644 --- a/Tests/Public/New-TeamViewerContact.Tests.ps1 +++ b/Tests/Public/New-TeamViewerContact.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerContact.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerContact.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerDevice.Tests.ps1 b/Tests/Public/New-TeamViewerDevice.Tests.ps1 index 055aa1b..bc61c1b 100644 --- a/Tests/Public/New-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/New-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerGroup.Tests.ps1 b/Tests/Public/New-TeamViewerGroup.Tests.ps1 index adc594f..6146f22 100644 --- a/Tests/Public/New-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/New-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 index 51f4a77..a1aaa36 100644 --- a/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/New-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerPolicy.Tests.ps1 b/Tests/Public/New-TeamViewerPolicy.Tests.ps1 index 8ca9745..06770fe 100644 --- a/Tests/Public/New-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/New-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerPolicy.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerUser.Tests.ps1 b/Tests/Public/New-TeamViewerUser.Tests.ps1 index e323143..38888a6 100644 --- a/Tests/Public/New-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/New-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerUser.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 index 2ee4b6d..dfc39e1 100644 --- a/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/New-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/New-TeamViewerUserRole.tests.ps1 b/Tests/Public/New-TeamViewerUserRole.tests.ps1 index ea41399..085e3e9 100644 --- a/Tests/Public/New-TeamViewerUserRole.tests.ps1 +++ b/Tests/Public/New-TeamViewerUserRole.tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/New-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerUserRole.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ForEach-Object { . $_.FullName } + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 b/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 index a7094fc..cde9ebe 100644 --- a/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Publish-TeamViewerGroup.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Publish-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Publish-TeamViewerGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 b/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 index 6e71775..e1c44da 100644 --- a/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerAssignment.Tests.ps1 @@ -1,9 +1,9 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerAssignment.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerVersion.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerAssignment.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerVersion.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } Describe 'Remove-TeamViewerAssignment' { diff --git a/Tests/Public/Remove-TeamViewerContact.Tests.ps1 b/Tests/Public/Remove-TeamViewerContact.Tests.ps1 index 92586de..800c0a5 100644 --- a/Tests/Public/Remove-TeamViewerContact.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerContact.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerContact.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerContact.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 b/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 index f09c30d..2a04c00 100644 --- a/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerCustomization.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerCustomization.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerCustomization.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } diff --git a/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 index da9e90e..27a8676 100644 --- a/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 index fa50ebd..e1f541e 100644 --- a/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 index ada1a56..c937a80 100644 --- a/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 index 424cd82..fab8909 100644 --- a/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManagedDeviceManagement.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerManagedDeviceManagement.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 index 078a111..c48f2be 100644 --- a/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerManager.Tests.ps1 b/Tests/Public/Remove-TeamViewerManager.Tests.ps1 index 4fc7af4..509bad4 100644 --- a/Tests/Public/Remove-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerManager.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 b/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 index 674b376..b93b118 100644 --- a/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerPSProxy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerPSProxy.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock -CommandName 'Remove-TeamViewerPSProxy' -MockWith { diff --git a/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 b/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 index 722e4c2..0e52ad1 100644 --- a/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPolicy.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 b/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 index 049729e..f6ed8af 100644 --- a/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerPolicyFromManagedDevice.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedDevice.ps1" - . "$PSScriptRoot/../../docs/TeamViewerPS.Types.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerPolicyFromManagedDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\TeamViewerPS.Types.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 b/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 index dbf9414..7666224 100644 --- a/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerRoleFromAccount.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 index 750e747..257b064 100644 --- a/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerRoleFromUserGroup.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerRoleFromUserGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 b/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 index 1054256..775a79a 100644 --- a/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerSsoExclusion.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerSsoExclusion.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerSsoExclusion.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerUser.Tests.ps1 b/Tests/Public/Remove-TeamViewerUser.Tests.ps1 index fc2ca78..3cbf5ef 100644 --- a/Tests/Public/Remove-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUser.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 index b282c0c..437dde1 100644 --- a/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 index e0d28e4..b0def83 100644 --- a/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroupMember.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUserGroupMember.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserGroupMember.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 index 3694839..eb9bd07 100644 --- a/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserRole.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Restart-TeamViewerService.Tests.ps1 b/Tests/Public/Restart-TeamViewerService.Tests.ps1 index 8bc37b8..b3e325d 100644 --- a/Tests/Public/Restart-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Restart-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Restart-TeamViewerService.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Restart-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Restart-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Set-TeamViewerAccount.Tests.ps1 b/Tests/Public/Set-TeamViewerAccount.Tests.ps1 index 78e7bc1..9b129f5 100644 --- a/Tests/Public/Set-TeamViewerAccount.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerAccount.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerAccount.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerAccount.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerDevice.Tests.ps1 b/Tests/Public/Set-TeamViewerDevice.Tests.ps1 index 8bdfadf..8ef476d 100644 --- a/Tests/Public/Set-TeamViewerDevice.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerGroup.Tests.ps1 index 04c8b76..fb1ab24 100644 --- a/Tests/Public/Set-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 index f88bc56..3e8fd17 100644 --- a/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedDevice.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerManagedDevice.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 index df73864..12eafe1 100644 --- a/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerManagedGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerManager.Tests.ps1 b/Tests/Public/Set-TeamViewerManager.Tests.ps1 index e600144..8057c73 100644 --- a/Tests/Public/Set-TeamViewerManager.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManager.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerManager.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerManager.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 b/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 index 9628118..fddb8ef 100644 --- a/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerPSProxy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerPSProxy.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ForEach-Object { . $_.FullName } + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerPSProxy.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerPSProxy.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } Mock -CommandName 'Set-TeamViewerPSProxy' -MockWith { param ( diff --git a/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 b/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 index d6d810b..78d49ba 100644 --- a/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerPolicy.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerPolicy.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerPolicy.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerUser.Tests.ps1 b/Tests/Public/Set-TeamViewerUser.Tests.ps1 index a1d4a95..b9dedfe 100644 --- a/Tests/Public/Set-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUser.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerUser.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 index 868dfd7..b5b79d0 100644 --- a/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUserGroup.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerUserGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} diff --git a/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 index de22d5b..2c3839e 100644 --- a/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerUserRole.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ForEach-Object { . $_.FullName } + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/Tests/Public/Start-TeamViewerService.Tests.ps1 b/Tests/Public/Start-TeamViewerService.Tests.ps1 index 31d450e..5b0bc24 100644 --- a/Tests/Public/Start-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Start-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Start-TeamViewerService.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Start-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Start-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Stop-TeamViewerService.Tests.ps1 b/Tests/Public/Stop-TeamViewerService.Tests.ps1 index f13eb36..92129f1 100644 --- a/Tests/Public/Stop-TeamViewerService.Tests.ps1 +++ b/Tests/Public/Stop-TeamViewerService.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Stop-TeamViewerService.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Stop-TeamViewerService.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } if (-Not (Get-Command -Name 'Stop-Service' -ErrorAction SilentlyContinue)) { diff --git a/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 b/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 index 8de6069..31f3fcc 100644 --- a/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 +++ b/Tests/Public/Test-TeamViewerConnectivity.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerConnectivity.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerConnectivity.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } Mock Test-TcpConnection { $true } diff --git a/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 b/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 index 59ddedb..9986f4f 100644 --- a/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 +++ b/Tests/Public/Test-TeamViewerInstallation.Tests.ps1 @@ -1,7 +1,7 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Get-TeamViewerInstallationDirectory.ps1" - . "$PSScriptRoot/../../docs/Cmdlets/Public/Test-TeamViewerInstallation.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerInstallationDirectory.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Test-TeamViewerInstallation.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } } diff --git a/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 b/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 index b9a96b7..53a9ab1 100644 --- a/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 +++ b/Tests/Public/Unpublish-TeamViewerGroup.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot/../../docs/Cmdlets/Public/Unpublish-TeamViewerGroup.ps1" - @(Get-ChildItem -Path "$PSScriptRoot/../../docs/Cmdlets/Private/*.ps1") | ` + . "$PSScriptRoot\..\..\Cmdlets\Public\Unpublish-TeamViewerGroup.ps1" + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken diff --git a/docs/TeamViewerPS.psm1 b/docs/TeamViewerPS.psm1 deleted file mode 100644 index e373072..0000000 --- a/docs/TeamViewerPS.psm1 +++ /dev/null @@ -1,6 +0,0 @@ -$ModuleTypes = @( Get-ChildItem -Path "$PSScriptRoot/TeamViewerPS.Types.ps1" -ErrorAction SilentlyContinue ) -$PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Cmdlets/Public/*.ps1" -ErrorAction SilentlyContinue ) -$PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Cmdlets/Private/*.ps1" -ErrorAction SilentlyContinue ) - -@($ModuleTypes + $PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } -Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * From f14e3a6b314f31ceeaf307b558e2016a06a5188d Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 28 Sep 2023 19:37:48 +0200 Subject: [PATCH 049/110] Copyright year --- Cmdlets/TeamViewerPS.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 04bbd70..6d62bf9 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -18,7 +18,7 @@ CompanyName = 'TeamViewer Germany GmbH' # Copyright statement for this module. - Copyright = '(c) 2021-2022 TeamViewer Germany GmbH. All rights reserved.' + Copyright = '(c) 2021-2023 TeamViewer Germany GmbH. All rights reserved.' # Description of the functionality provided by this module. Description = 'TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally installed TeamViewer client.' @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerRoleToAccount', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() From 80d518141cd1389a788910259ae3636888ed38fd Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 28 Sep 2023 19:48:19 +0200 Subject: [PATCH 050/110] Formatting TeamViewerPS.psd1 --- Cmdlets/TeamViewerPS.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 6d62bf9..67b1bf3 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerRoleToAccount', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() From f275e115b938aca4a29358b48e8a03fc5d0b6a54 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 28 Sep 2023 19:59:06 +0200 Subject: [PATCH 051/110] Add missing ) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0e079d..c722018 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,4 +46,4 @@ jobs: $ProgressPreference = 'SilentlyContinue' $ErrorActionPreference = 'Stop' Install-Module -Name platyPS, BuildHelpers -SkipPublisherCheck -Scope CurrentUser -Force - & (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Build\New-Package.ps1' -Verbose + & (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Build\New-Package.ps1') -Verbose From 64a75651e96de5ee1809904a13e452edc98ca925 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 28 Sep 2023 20:22:11 +0200 Subject: [PATCH 052/110] Fixed change log --- CHANGELOG.md | 26 +++++++++++++------------- README.md | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5831d60..bde41c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,24 +4,24 @@ ### Added - -Added 'Set-TeamViewerApiURi' to use TeamViewer test API. - -Added user role commands to remotely manage user roles of a TeamViewer company. - -Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. - -Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. - -Added `Export-TeamViewerSystemInformation` to create zip file for support. - -Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. - -Added `Get-TeamViewerInstallationDirectory` to return installation directory. - -Added `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. +- Added 'Set-TeamViewerApiURi' to use TeamViewer test API. +- Added user role commands to remotely manage user roles of a TeamViewer company. +- Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. +- Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. +- Added `Export-TeamViewerSystemInformation` to create zip file for support. +- Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. +- Added `Get-TeamViewerInstallationDirectory` to return installation directory. +- Added `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. ### Changed - -Extended `Invoke-TeamViewerPackageDownload` with MSI package type. - -Folder structure modified. - -`-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. +- Extended `Invoke-TeamViewerPackageDownload` with MSI package type. +- Folder structure modified. +- `-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. ### Fixed - -Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. +- Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. ## 1.5.2 (2023-09-18) @@ -37,7 +37,7 @@ ### Added - Added `Remove-TeamViewerUser` cmdlet to remove user from TeamViewer company. (Thanks @OtterKring) -- Added `Remove-TeamViewerManagedDeviceManagement` to unmanage a device. +- Added `Remove-TeamViewerManagedDeviceManagement` to un-manage a device. ### Changed diff --git a/README.md b/README.md index d7a0812..8ad79cb 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Connect-TeamViewerApi # Retrieves users of a TeamViewer company Get-TeamViewerUser ``` + Another example below shows how to display the TeamViewer ID as well as the version of the locally installed TeamViewer client: From 1eca34dd0df865629f0eea2162e1c3d5ca0c3c6c Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 28 Sep 2023 20:25:50 +0200 Subject: [PATCH 053/110] Modified change log and readme --- CHANGELOG.md | 4 ++-- README.md | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bde41c5..4288e26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Added - Added 'Set-TeamViewerApiURi' to use TeamViewer test API. -- Added user role commands to remotely manage user roles of a TeamViewer company. +- Added commands to remotely manage user roles of a TeamViewer company. - Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. - Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. - Added `Export-TeamViewerSystemInformation` to create zip file for support. @@ -16,8 +16,8 @@ ### Changed - Extended `Invoke-TeamViewerPackageDownload` with MSI package type. -- Folder structure modified. - `-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. +- Optimized folder structure. ### Fixed diff --git a/README.md b/README.md index 8ad79cb..2332750 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ ![CI](https://github.com/teamviewer/TeamViewerPS/workflows/CI/badge.svg) -TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally -installed TeamViewer client. +TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally installed TeamViewer client. ## Installation & Update @@ -13,8 +12,7 @@ Install TeamViewerPS from the Powershell Gallery using the following command: Install-Module TeamViewerPS ``` -Execute the following command to update an existing installation of -TeamViewerPS: +Execute the following command to update an existing installation of TeamViewerPS: ```powershell Update-Module TeamViewerPS @@ -22,8 +20,7 @@ Update-Module TeamViewerPS ## Usage -The following example code shows how to interact with the TeamViewer Web API -functions by retrieving the list of users of a TeamViewer company: +The following example code shows how to interact with the TeamViewer Web API functions by retrieving the list of users of a TeamViewer company: ```powershell # Downloads and installs the module from Powershell Gallery @@ -38,8 +35,7 @@ Connect-TeamViewerApi Get-TeamViewerUser ``` -Another example below shows how to display the TeamViewer ID as well as the -version of the locally installed TeamViewer client: +Another example below shows how to display the TeamViewer ID as well as the version of the locally installed TeamViewer client: ```powershell Install-Module TeamViewerPS @@ -76,8 +72,7 @@ The module provides functions for the following categories: - _Single Sign-On management_ - _Local TeamViewer utilities_ -Please see the [about_TeamViewerPS](docs/about_TeamViewerPS.md) article for a -more detailed list. +Please see the [about_TeamViewerPS](docs/about_TeamViewerPS.md) article for a more detailed list. ## Prerequisites @@ -89,7 +84,7 @@ TeamViewerPS requires one of the following environments to run: ## License -Please see the file `LICENSE`. +Please see the file `LICENSE.md`. ## Links From d07eca3254d3ba80d8c632a16fa5eff6b7cb7e93 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 12:11:14 +0200 Subject: [PATCH 054/110] Fix CHANGELOG.md list format Fix CHANGELOG.md list format --- CHANGELOG.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5831d60..72afa01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,24 +4,24 @@ ### Added - -Added 'Set-TeamViewerApiURi' to use TeamViewer test API. - -Added user role commands to remotely manage user roles of a TeamViewer company. - -Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. - -Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. - -Added `Export-TeamViewerSystemInformation` to create zip file for support. - -Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. - -Added `Get-TeamViewerInstallationDirectory` to return installation directory. - -Added `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. +- Added 'Set-TeamViewerApiURi' to use TeamViewer test API. +- Added user role commands to remotely manage user roles of a TeamViewer company. +- Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. +- Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. +- Added `Export-TeamViewerSystemInformation` to create zip file for support. +- Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. +- Added `Get-TeamViewerInstallationDirectory` to return installation directory. +- Added `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. ### Changed - -Extended `Invoke-TeamViewerPackageDownload` with MSI package type. - -Folder structure modified. - -`-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. +- Extended `Invoke-TeamViewerPackageDownload` with MSI package type. +- Folder structure modified. +- `-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. ### Fixed - -Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. +- Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. ## 1.5.2 (2023-09-18) From 9c152e9c20035f4ec86b4c5d49f26f1b9eaeb918 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:47:40 +0200 Subject: [PATCH 055/110] Delete .github/workflows/powershell-analysis.yml Delete file ".github/workflows/powershell-analysis.yml", as not needed (anymore) from my perspective --- .github/workflows/powershell-analysis.yml | 42 ----------------------- 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/powershell-analysis.yml diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml deleted file mode 100644 index cd0427c..0000000 --- a/.github/workflows/powershell-analysis.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# -# https://github.com/microsoft/action-psscriptanalyzer -# For more information on PSScriptAnalyzer in general, see -# https://github.com/PowerShell/PSScriptAnalyzer - -name: PSScriptAnalyzer - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - schedule: - - cron: '23 3 * * 5' - -jobs: - build: - name: PSScriptAnalyzer - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - - name: Run PSScriptAnalyzer - uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 - with: - # Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options. - # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. - path: .\ - recurse: true - # Exclude your own basic security rules. Removing this option will run all the rules - excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' - output: results.sarif - - # Upload the SARIF file generated in the previous step - - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: results.sarif From af0820ea4175e52236d000801f72fbc954e2e380 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:53:47 +0200 Subject: [PATCH 056/110] Update publish_production.yml Update publish_production.yml --- .github/workflows/publish_production.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 8b5fc43..301c8bb 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -1,4 +1,4 @@ -name: PublishProduction +name: Publish_Production on: workflow_dispatch: @@ -10,8 +10,10 @@ jobs: runs-on: windows-latest steps: + # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it - uses: actions/checkout@v3 + # Build package - name: Build package shell: pwsh run: | @@ -19,12 +21,11 @@ jobs: Install-Module platyPS,BuildHelpers -Force -SkipPublisherCheck -Scope CurrentUser & $env:GITHUB_WORKSPACE/Build/New-Package.ps1 -Verbose - - name: Publish to powershellgallery.com + # Publish to PowershellGallery.com + - name: Publish to PowershellGallery.com env: NUGET_APIKEY_PRODUCTION: ${{ secrets.NUGET_APIKEY_PRODUCTION }} shell: pwsh run: | $ProgressPreference='SilentlyContinue' - Publish-Module ` - -Path $env:GITHUB_WORKSPACE/Build/Output/ ` - -NuGetApiKey $env:NUGET_APIKEY_PRODUCTION + Publish-Module -Path $env:GITHUB_WORKSPACE/Build/Output/ -NuGetApiKey $env:NUGET_APIKEY_PRODUCTION From 987e781bb1fa0e339fed5e6b3370947eb8722157 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 19:15:09 +0200 Subject: [PATCH 057/110] Move about_TeamViewerPS.md to Docs folder Move about_TeamViewerPS.md to ./Docs folder --- {Cmdlets => Docs}/about_TeamViewerPS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {Cmdlets => Docs}/about_TeamViewerPS.md (100%) diff --git a/Cmdlets/about_TeamViewerPS.md b/Docs/about_TeamViewerPS.md similarity index 100% rename from Cmdlets/about_TeamViewerPS.md rename to Docs/about_TeamViewerPS.md From 82e7d1790352a5b1f9a064e9ab1b60b8c47e88bb Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:05:00 +0200 Subject: [PATCH 058/110] Update TeamViewerPS.psd1 Update TeamViewerPS.psd1 --- Cmdlets/TeamViewerPS.psd1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 67b1bf3..3e6c9d8 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -1,4 +1,4 @@ -@{ +@{ # Script module or binary module file associated with this manifest. RootModule = 'TeamViewerPS.psm1' @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerRoleToAccount', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() @@ -82,14 +82,14 @@ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. PrivateData = @{ - PSData = @{ - #Prerelease = '-alpha1' - # Tags applied to this module. These help with module discovery in online galleries. # Tags = @() Tags = @( + 'PowerShell', + 'scripting', + 'automation', 'teamviewer', 'remotecontrol', 'webapi', @@ -97,20 +97,19 @@ ) # A URL to the license for this module. - LicenseUri = 'https://github.com/teamviewer/TeamViewerPS/blob/main/LICENSE' + LicenseUri = 'https://github.com/teamviewer/TeamViewerPS/blob/main/LICENSE.md' # A URL to the main website for this project. ProjectUri = 'https://github.com/teamviewer/TeamViewerPS' # ReleaseNotes of this module. - # ReleaseNotes = 'Initial release' + # ReleaseNotes = 'https://github.com/teamviewer/TeamViewerPS/blob/main/CHANGELOG.md' } # End of PSData hashtable - } # End of PrivateData hashtable # HelpInfo URI of this module. - # HelpInfoURI = '' + # HelpInfoURI = 'https://github.com/teamviewer/TeamViewerPS/tree/main/Docs' # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' From c5fba7b3764c0c5cf54692d12321ab7ab6a60d79 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:08:15 +0200 Subject: [PATCH 059/110] Update extensions.json --- .vscode/extensions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f812c74..620f096 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,6 +2,7 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 for the documentation about the extensions.json format "recommendations": [ "ms-vscode.PowerShell", - "DavidAnson.vscode-markdownlint" + "DavidAnson.vscode-markdownlint", + "streetsidesoftware.code-spell-checker" ] } From 15af5ba68f7e67acdade7ec836075d3f8b4a8e28 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:10:09 +0200 Subject: [PATCH 060/110] Update launch.json --- .vscode/launch.json | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 16824b2..049e590 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,22 +1,20 @@ { - // See https://go.microsoft.com/fwlink/?linkid=830387 for the documentation about the launch.json format + // See https://go.microsoft.com/fwlink/?linkid=830387 for the documentation about the tasks.json format "version": "0.2.0", "configurations": [ { - "name": "Test (via Pester)", + "name": "Lint (via PSScriptAnalyzer)", "type": "PowerShell", "request": "launch", - "script": "Invoke-Pester", - "args": [ - "-Path '${workspaceFolder}' -Output Detailed" - ] + "script": "Invoke-ScriptAnalyzer -Path '${workspaceFolder}' -Recurse -Settings '${workspaceFolder}/Linters/PSScriptAnalyzer.psd1'", + "createTemporaryIntegratedConsole": true }, { - "name": "Run (via PowerShell)", + "name": "Test (via Pester)", "type": "PowerShell", "request": "launch", - "cwd": "${workspaceRoot}", - "args": [] + "script": "Invoke-Pester -Path '${workspaceFolder}'", + "createTemporaryIntegratedConsole": true } ] } From bb59b47d64d4e6a333443ecad06656dd51a2097f Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:15:13 +0200 Subject: [PATCH 061/110] Update settings.json --- .vscode/settings.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ee91085..0a4afa5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -41,12 +41,12 @@ }, "cSpell.dictionaryDefinitions": [ { - "name": "customDictionary", - "path": "./.spelling" + "name": "ProjectDictionary", + "path": "${workspaceRoot}/.vscode/spelling" } ], "cSpell.dictionaries": [ - "customDictionary" + "ProjectDictionary" ], - "cSpell.language": "en" + "cSpell.language": "en", } From f3db120db7e1768a7c589e3977ed1b742cc97091 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:15:27 +0200 Subject: [PATCH 062/110] Rename .spelling to spelling --- .vscode/{.spelling => spelling} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .vscode/{.spelling => spelling} (100%) diff --git a/.vscode/.spelling b/.vscode/spelling similarity index 100% rename from .vscode/.spelling rename to .vscode/spelling From e6d491b8ff5f892df41282bd82c236166108dffd Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:17:36 +0200 Subject: [PATCH 063/110] Update tasks.json --- .vscode/tasks.json | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9274ea4..9c29388 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,15 +5,20 @@ { "label": "Lint (via PSScriptAnalyzer)", "type": "shell", - "command": "Invoke-ScriptAnalyzer -Path '${workspaceFolder}/Linters' -Severity Information, Warning, Error -Recurse", + "command": "& Invoke-ScriptAnalyzer -Path \\\"${workspaceFolder}\\\" -Recurse -Settings \\\"${workspaceFolder}/Linters/PSScriptAnalyzer.psd1\\\"", "group": { - "kind": "build", + "kind": "test", "isDefault": true - }, - "presentation": { - "reveal": "always" - }, - "problemMatcher": [] + } + }, + { + "label": "Test (via Pester)", + "type": "shell", + "command": "& Invoke-Pester -Path \\\"${workspaceFolder}\\\"", + "group": { + "kind": "test", + "isDefault": false + } }, { "label": "Clean", From 41b9c65cb1f03277e1fdb317c4e059920edea508 Mon Sep 17 00:00:00 2001 From: Karthick Gandhi Date: Mon, 9 Oct 2023 01:02:28 +0200 Subject: [PATCH 064/110] Documentation and module file update Chnages resolved Typo fix Web API proxy included in documentation Documentation update --- Cmdlets/TeamViewerPS.psm1 | 5853 +----------------------------------- Docs/TeamViewerPS.md | 260 ++ Docs/about_TeamViewerPS.md | 199 -- README.md | 4 +- 4 files changed, 267 insertions(+), 6049 deletions(-) create mode 100644 Docs/TeamViewerPS.md delete mode 100644 Docs/about_TeamViewerPS.md diff --git a/Cmdlets/TeamViewerPS.psm1 b/Cmdlets/TeamViewerPS.psm1 index 8f8353d..d91058d 100644 --- a/Cmdlets/TeamViewerPS.psm1 +++ b/Cmdlets/TeamViewerPS.psm1 @@ -1,5849 +1,6 @@ -enum TeamViewerConnectionReportSessionType { - RemoteConnection = 1 - RemoteSupportActive = 2 - RemoteSupportActiveSdk = 3 -} - -enum PolicyType { - TeamViewer = 1 - Monitoring = 4 - PatchManagement = 5 -} - - - -function Add-Registry { - param ( - [Microsoft.Win32.RegistryKey]$RegKey, - [string]$Program - ) - - #CustomObject including all information for each registry and sub keys - $retRegKey = [PSCustomObject]@{ - Program = $Program - RegistryPath = $RegKey.Name - Entries = @() - } - Write-Output "Collecting registry data $($retRegKey.RegistryPath)" - foreach ($valueName in $RegKey.GetValueNames()) { - $value = $RegKey.GetValue($valueName) - $type, $value = Get-TypeAndValueOfRegistryValue -RegKey $RegKey -ValueName $valueName - $blackList = @('BuddyLoginTokenAES', 'BuddyLoginTokenSecretAES', 'Certificate', 'CertificateKey', 'CertificateKeyProtected', - 'MultiPwdMgmtPwdData', 'PermanentPassword', 'PK', 'SecurityPasswordAES', 'SK', 'SRPPasswordMachineIdentifier') - foreach ($blackListValue in $blackList) { - if ($valueName -eq $blackListValue) { - $value = '___PRIVATE___' - } - } - $entry = [PSCustomObject]@{ - Name = $valueName - Value = $value - Type = $type - } - $retRegKey.Entries += $entry - } - - foreach ($subKeyName in $RegKey.GetSubKeyNames()) { - $subKey = $RegKey.OpenSubKey($subKeyName) - Add-Registry -RegKey $subKey -Program $subKeyName - } - #Adding CustomObject to array declared in Get-RegistryPaths - $AllTVRegistryData.Add($retRegKey) | Out-Null -} - - - - - -function ConvertTo-DateTime { - param( - [Parameter(ValueFromPipeline)] - [string] - $InputString - ) - - process { - try { - Write-Output ([DateTime]::Parse($InputString)) - } - catch { - Write-Output $null - } - } -} - - -function ConvertTo-ErrorRecord { - param( - [Parameter(ValueFromPipeline)] - [object] - $InputObject, - - [Parameter()] - [System.Management.Automation.ErrorCategory] - $ErrorCategory = [System.Management.Automation.ErrorCategory]::NotSpecified - ) - Process { - $category = $ErrorCategory - $message = $InputObject.ToString() - $errorId = 'TeamViewerError' - - if ($InputObject.PSObject.TypeNames -contains 'TeamViewerPS.RestError') { - $category = switch ($InputObject.ErrorCategory) { - 'invalid_request' { [System.Management.Automation.ErrorCategory]::InvalidArgument } - 'invalid_token' { [System.Management.Automation.ErrorCategory]::AuthenticationError } - 'internal_error' { [System.Management.Automation.ErrorCategory]::NotSpecified } - 'rate_limit_reached' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } - 'token_expired' { [System.Management.Automation.ErrorCategory]::AuthenticationError } - 'wrong_credentials' { [System.Management.Automation.ErrorCategory]::AuthenticationError } - 'invalid_client' { [System.Management.Automation.ErrorCategory]::InvalidArgument } - 'not_found' { [System.Management.Automation.ErrorCategory]::ObjectNotFound } - 'too_many_retries' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } - 'invalid_permission' { [System.Management.Automation.ErrorCategory]::PermissionDenied } - default { [System.Management.Automation.ErrorCategory]::NotSpecified } - } - $errorId = 'TeamViewerRestError' - } - - $exception = [System.Management.Automation.RuntimeException]($message) - $errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $category, $null - $errorRecord.ErrorDetails = $message - return $errorRecord - } -} - - - -function ConvertTo-TeamViewerAccount { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Name = $InputObject.name - Email = $InputObject.email - UserId = $InputObject.userid - CompanyName = $InputObject.company_name - IsEmailValidated = $InputObject.email_validated - EmailLanguage = $InputObject.email_language - } - if ($InputObject.email_language -And $InputObject.email_language -Ne 'auto') { - $properties["EmailLanguage"] = [System.Globalization.CultureInfo]($InputObject.email_language) - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Account') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name) <$($this.Email)>" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerAuditEvent { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Name = $InputObject.EventName - Type = $InputObject.EventType - Timestamp = $InputObject.Timestamp | ConvertTo-DateTime - Author = $InputObject.Author - AffectedItem = $InputObject.AffectedItem - EventDetails = $InputObject.EventDetails - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.AuditEvent') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "[$($this.Timestamp)] $($this.Name) ($($this.Type))" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerConnectionReport { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.id - UserId = $InputObject.userid - UserName = $InputObject.username - DeviceId = $InputObject.deviceid - DeviceName = $InputObject.devicename - GroupId = $InputObject.groupid - GroupName = $InputObject.groupname - SupportSessionType = [TeamViewerConnectionReportSessionType]$InputObject.support_session_type - StartDate = $InputObject.start_date | ConvertTo-DateTime - EndDate = $InputObject.end_date | ConvertTo-DateTime - SessionCode = $InputObject.session_code - Fee = $InputObject.fee - BillingState = $InputObject.billing_state - Currency = $InputObject.currency - Notes = $InputObject.notes - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ConnectionReport') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerContact { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.contact_id - UserId = $InputObject.user_id - GroupId = $InputObject.groupid - Name = $InputObject.name - Description = $InputObject.description - OnlineState = $InputObject.online_state - ProfilePictureUrl = $InputObject.profilepicture_url - SupportedFeatures = $InputObject.supported_features - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Contact') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerDevice { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $remoteControlId = $InputObject.remotecontrol_id | ` - Select-String -Pattern 'r(\d+)' | ` - ForEach-Object { $_.Matches.Groups[1].Value } - $properties = @{ - Id = $InputObject.device_id - TeamViewerId = $remoteControlId - GroupId = $InputObject.groupid - Name = $InputObject.alias - Description = $InputObject.description - OnlineState = $InputObject.online_state - IsAssignedToCurrentAccount = $InputObject.assigned_to - SupportedFeatures = $InputObject.supported_features - } - if ($InputObject.policy_id) { - $properties['PolicyId'] = $InputObject.policy_id - } - if ($InputObject.last_seen) { - $properties['LastSeenAt'] = [datetime]($InputObject.last_seen) - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Device') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.id - Name = $InputObject.name - Permissions = $InputObject.permissions - SharedWith = @($InputObject.shared_with | ConvertTo-TeamViewerGroupShare) - } - if ($InputObject.owner) { - $properties.Owner = [pscustomobject]@{ - UserId = $InputObject.owner.userid - Name = $InputObject.owner.name - } - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Group') - Write-Output $result - } -} - - -function ConvertTo-TeamViewerGroupShare { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - UserId = $InputObject.userid - Name = $InputObject.name - Permissions = $InputObject.permissions - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.GroupShare') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.UserId)" - } - Write-Output $result - } -} - - -function ConvertTo-TeamViewerManagedDevice { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [guid]$InputObject.id - Name = $InputObject.name - TeamViewerId = $InputObject.TeamViewerId - IsOnline = $InputObject.isOnline - } - - if ($InputObject.last_seen) { - $properties['LastSeenAt'] = Get-Date -Date $InputObject.last_seen - } - - if ($InputObject.teamviewerPolicyId) { - $properties["PolicyId"] = [guid]$InputObject.teamviewerPolicyId - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedDevice') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerManagedGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [guid]$InputObject.id - Name = $InputObject.name - } - if ($InputObject.policy_id) { - $properties["PolicyId"] = $InputObject.policy_id - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedGroup') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerManager { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject, - - [Parameter(Mandatory = $true, ParameterSetName = "GroupManager")] - [guid] - $GroupId, - - [Parameter(Mandatory = $true, ParameterSetName = "DeviceManager")] - [guid] - $DeviceId - ) - process { - $properties = @{ - Id = [guid]$InputObject.id - ManagerType = $InputObject.type - Name = $InputObject.name - Permissions = $InputObject.permissions - } - - switch ($InputObject.type) { - 'account' { - $properties.AccountId = $InputObject.accountId - } - 'company' { - $properties.CompanyId = $InputObject.companyId - } - } - - switch ($PsCmdlet.ParameterSetName) { - 'GroupManager' { - $properties.GroupId = $GroupId - } - 'DeviceManager' { - $properties.DeviceId = $DeviceId - } - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Manager') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerPolicy { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - - process { - $properties = @{ - Id = $InputObject.policy_id - Name = $InputObject.name - Settings = @( - $InputObject.settings | ForEach-Object { - @{ - Key = $_.key - Value = $_.value - Enforce = $_.enforce - } - } - ) - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Policy') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerRestError { - param( - [parameter(ValueFromPipeline)] - $InputError - ) - Process { - try { - $errorObject = ($InputError | Out-String | ConvertFrom-Json) - $result = [PSCustomObject]@{ - Message = $errorObject.error_description - ErrorCategory = $errorObject.error - ErrorCode = $errorObject.error_code - ErrorSignature = $errorObject.error_signature - } - $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { - Write-Output "$($this.Message) ($($this.ErrorCategory))" - } - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RestError') - return $result - } - catch { - return $InputError - } - } -} - - - -function ConvertTo-TeamViewerRoleAssignedUser { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{AssignedUsers = ($InputObject.trim('u'))} - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUser') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerRoleAssignedUserGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{AssignedGroups = ($InputObject)} - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUserGroup') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerSsoDomain { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.DomainId - Name = $InputObject.DomainName - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.SsoDomain') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUser { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject, - - [Parameter()] - [ValidateSet('All', 'Minimal')] - $PropertiesToLoad = 'All' - ) - process { - $properties = @{ - Id = $InputObject.id - Name = $InputObject.name - Email = $InputObject.email - } - if ($PropertiesToLoad -Eq 'All') { - $properties += @{ - Permissions = $InputObject.permissions -split ',' - Active = $InputObject.active - LastAccessDate = $InputObject.last_access_date | ConvertTo-DateTime - } - if ($InputObject.activated_license_id) { - $properties += @{ - ActivatedLicenseId = [guid]$InputObject.activated_license_id - ActivatedLicenseName = $InputObject.activated_license_name - ActivatedSubLicenseName = $InputObject.activated_subLicense_name - } - } - if ($InputObject.activated_meeting_license_key) { - $properties += @{ - ActivatedMeetingLicenseId = [guid]$InputObject.activated_meeting_license_key - } - } - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.User') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name) <$($this.Email)>" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUserGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [UInt64]$InputObject.id - Name = $InputObject.name - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroup') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUserGroupMember { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - AccountId = [int]$InputObject.accountId - Name = $InputObject.name - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroupMember') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUserRole { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - RoleName = $InputObject.Name - RoleID = $InputObject.Id - } - if ($InputObject.Permissions) { - foreach ($permission in $InputObject.Permissions.PSObject.Properties) { - $properties[$permission.Name] = $permission.Value - } - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserRole') - $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { - Write-Output "[$($this.RoleName)] [$($this.RoleID)] $($this.Permissions))" - } - Write-Output $result - } -} - - - - -function Get-ClientId { - if (Test-Path -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer') { - $mainKey = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' - $id = [int]$mainKey.ClientID - } - elseif (Test-Path -Path 'HKLM:\Software\TeamViewer') { - $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' - $id = [int]$mainKey.ClientID - } - return $id -} - - - -function Get-HostFile { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - process { - $regPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' - $regKey = Get-ItemProperty -Path $regPath - $hostsPath = Join-Path -Path $regKey.DataBasePath -ChildPath 'hosts' - $hostsFile = Get-Content -Path $hostsPath - $hostsFile | Out-File -FilePath "$OutputPath\Data\hosts.txt" - Write-Output "hosts file collected and saved to $OutputPath\Data\hosts.txt" - } -} - - - -function Get-InstalledSoftware { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Begin { - $regUninstall = @{ - InstalledSoftware32 = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' - InstalledSoftware64 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' - } - } - Process { - foreach ($Name in $regUninstall.keys) { - $regKeys = $regUninstall[$Name] - $regKey = Get-ItemProperty -Path "$regKeys\*" - if ($null -ne $regKey) { - $subKeys = $regKey.PSChildName - if ($null -ne $subKeys) { - $installedPrograms = @() - foreach ($subKey in $subKeys) { - $tmpSubkey = Get-ItemProperty -Path "$regKeys\$subKey" - $programmName = $tmpSubkey.DisplayName - $displayVersion = $tmpSubkey.DisplayVersion - if ($null -ne $programmName) { - $tmpSoftwareData = "$programmName | $displayVersion" - $installedPrograms += $tmpSoftwareData - } - } - } - $installedPrograms | Sort-Object | Out-File -FilePath "$OutputPath\Data\$Name.txt" - Write-Output "$Name collected and saved to $OutputPath\Data\$Name.txt" - } - } - } -} - - - - - -function Get-IpConfig { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Process { - try { - ipconfig /all | Out-File -FilePath "$OutputPath\Data\ipconfig.txt" -Encoding utf8 - Write-Output "ipconfig data collected and saved to $OutputPath\Data\ipconfig.txt" - } - catch { - Write-Error "An error occurred while collecting ipconfig data: $_" - } - } -} - - - -function Get-MSInfo32 { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Process { - try { - Start-Process -FilePath msinfo32.exe -ArgumentList "/nfo $OutputPath\Data\msinfo32.nfo" -Wait - - Write-Output "msinfo data collected and saved to $OutputPath\Data\msinfo32.nfo" - } - catch { - Write-Error "An error occurred while collecting msinfo data: $_" - } - } -} - - - -function Get-NSLookUpData { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Begin { - $Ipv4DnsServer = @($null, 'tv-ns1.teamviewer.com', 'tv-ns2.teamviewer.com', 'tv-ns3.teamviewer.com', - 'tv-ns4.teamviewer.com', 'tv-ns5.teamviewer.com', '8.8.8.8', '1.1.1.1') - $Ipv4DnsName = @( 'master1.teamviewer.com', 'router1.teamviewer.com', 'google.com', - 'login.teamviewer.com', 'www.teamviewer.com') - $output = $null - } - Process { - try { - foreach ($DnsName in $Ipv4DnsName ) { - foreach ($DnsServer in $Ipv4DnsServer) { - Write-Output "Collecting nslookup.exe information from $DnsName $DnsServer. This might take a while" - $output += "nslookup information for: $DnsName $DnsServer `r`n" - $arguments = "-debug ""$DnsName""" - if ($DnsServer) { - $arguments += " ""$DnsServer""" - } - $processInfo = New-Object System.Diagnostics.ProcessStartInfo - $processInfo.FileName = 'nslookup.exe' - $processInfo.Arguments = $arguments - $processInfo.WindowStyle = 'Hidden' - $processInfo.UseShellExecute = $false - $processInfo.RedirectStandardOutput = $true - - $process = [System.Diagnostics.Process]::Start($processInfo) - $output += $process.StandardOutput.ReadToEnd() - $process.WaitForExit(60000) - if (-not $process.HasExited) { - $process.Kill() - continue - } - $output += $process.StandardOutput.ReadToEnd() - } - } - $output | Out-File "$OutputPath\Data\nslookup.txt" - } - - catch { - Write-Error "Error collecting nslookup information: $_" - } - } -} - - - - - -function Get-OperatingSystem { - if ($IsLinux) { - return 'Linux' - } - if ($IsMacOS) { - return 'MacOS' - } - if ($IsWindows -Or $env:OS -match '^Windows') { - return 'Windows' - } -} - - - -function Get-RegistryPath { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Begin { - $SearchProgramms = @('TeamViewer', 'Blizz', 'TeamViewerMeeting') - $RegistrySearchPathsLocalMachine = @('SOFTWARE\Wow6432Node', 'SOFTWARE') - $RegistrySearchPathsCurrentUser = @('SOFTWARE') - $AllTVRegistryData = New-Object System.Collections.ArrayList - } - - Process { - foreach ($searchProgramm in $SearchProgramms) { - foreach ($registrySearchPath in $RegistrySearchPathsLocalMachine) { - $regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$registrySearchPath\$searchProgramm", $false) - if ($regKey) { - Add-Registry -RegKey $regKey -Program $searchProgramm - } - } - - foreach ($registrySearchPath in $RegistrySearchPathsCurrentUser) { - $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm", $false) - if ($searchProgramm -eq 'Blizz' -or $searchProgramm -eq 'TeamViewerMeeting') { - $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm\MachineFallback", $false) - } - if ($regKey) { - Add-Registry -RegKey $regKey -Program $searchProgramm - } - } - - $output = "Windows Registry Editor Version 5.00 `r`n" - foreach ($data in $AllTVRegistryData) { - $output += "[$($data.RegistryPath)]`r`n" - foreach ($entry in $data.Entries) { - if ($null -ne $entry.name) { - $output += """$($entry.Name)""" + $entry.Type + $entry.Value + "`r`n" - } - } - $output += "`r`n" - } - $output | Out-File -FilePath "$OutputPath\Data\TeamViewer_Version15\Reg_Version15.txt" - } - } - -} - - - -function Get-RouteTable { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) -Process{ - try { - $processInfo = New-Object System.Diagnostics.ProcessStartInfo - $processInfo.FileName = 'route.exe' - $processInfo.Arguments = 'print' - $processInfo.WindowStyle = 'Hidden' - $processInfo.UseShellExecute = $false - $processInfo.RedirectStandardOutput = $true - - $process = [System.Diagnostics.Process]::Start($processInfo) - $output = $process.StandardOutput.ReadToEnd() - $output | Out-File "$OutputPath\Data\RouteTable.txt" - } - catch { - Write-Error "An error occurred while collecting RouteTable data: $_" - } -} -} - - - - - -class TeamViewerConfiguration { - [string]$APIUri = 'https://webapi.teamviewer.com/api/v1' - - static [TeamViewerConfiguration] $Instance = $null - - static [TeamViewerConfiguration] GetInstance() { - if (-not [TeamViewerConfiguration]::Instance) { - [TeamViewerConfiguration]::Instance = [TeamViewerConfiguration]::new() - } - - return [TeamViewerConfiguration]::Instance - } -} - -function Get-TeamViewerAPIUri { - $config = [TeamViewerConfiguration]::GetInstance() - return $config.APIUri -} - - - - - -function Get-TeamViewerLinuxGlobalConfig { - param( - [Parameter()] - [string] - $Path = '/opt/teamviewer/config/global.conf', - - [Parameter()] - [string] - $Name - ) - $config = & sudo pwsh -command Get-Content $Path | ForEach-Object { - if ($_ -Match '\[(?\w+)\s*\]\s+(?[\w\\]+)\s+=\s*(?.*)$') { - $Matches.Remove(0) - $entry = [pscustomobject]$Matches - switch ($entry.EntryType) { - 'strng' { - $entry.EntryValue = $entry.EntryValue | ` - Select-String -Pattern '"([^\"]*)"' -AllMatches | ` - Select-Object -ExpandProperty Matches | ` - ForEach-Object { $_.Groups[1].Value } - } - 'int32' { - $entry.EntryValue = [int32]($entry.EntryValue) - } - 'int64' { - #In some cases the EntryName DeviceManagement/TransitionNonces is set to entryvalue '0 0 0 0 0' of type int64 - if ($entry.EntryValue -notmatch '0 0 0 0 0') { - $entry.EntryValue = [int64]($entry.EntryValue) - } - } - } - $entry - } - } - - if ($Name) { - ($config | Where-Object { $_.EntryName -eq $Name }).EntryValue - } - else { - $config - } -} - - - -function Get-TeamViewerRegKeyPath { - param ( - [Parameter()] - [ValidateSet('WOW6432', 'Auto')] - [string] - $Variant = 'Auto' - ) - if (($Variant -eq 'WOW6432') -Or (Test-TeamViewer32on64)) { - Write-Output 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' - } - else { - Write-Output 'HKLM:\SOFTWARE\TeamViewer' - } -} - - - -function Get-TeamViewerServiceName { - Write-Output 'TeamViewer' -} - - - -function Get-TSCDirectoryFile { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - - Process { - $SearchDirectories = Get-TSCSearchDirectory - $TempDirectory = New-Item -Path $OutputPath -Name 'Data' -ItemType Directory -Force - $Endings = @('.log', 'tvinfo.ini', '.mdmp', 'Connections.txt', 'Connections_incoming.txt') - $TmpLogFiles = @() - foreach ($Name in $SearchDirectories.Keys) { - $SearchDirectory = $SearchDirectories[$Name] - foreach ($Folder in $SearchDirectory) { - if (Test-Path -Path $Folder) { - $TempSubdirectory = Join-Path -Path $TempDirectory -ChildPath $Name - New-Item -Path $TempSubdirectory -ItemType Directory -Force | Out-Null - $files = Get-ChildItem -Path $Folder -File -Recurse - foreach ($file in $files) { - foreach ($ending in $Endings) { - if ($file.Name.EndsWith($ending)) { - $tmpLogfilePath = Join-Path -Path $TempSubdirectory -ChildPath $file.Name - Copy-Item -Path $file.FullName -Destination $tmpLogfilePath -Force - $TmpLogFiles += $tmpLogfilePath - Write-Output "Collected log file from $($file.FullName)" - } - } - } - } - } - } - Write-Output 'Files from TeamViewer directories have been collected.' - } -} - - - -function Get-TSCSearchDirectory { - $LocalAppData = [System.Environment]::GetFolderPath('LocalApplicationData') - $RoamingAppData = [System.Environment]::GetFolderPath('ApplicationData') - $TVAppData = Join-Path -Path $LocalAppData.ToString() -ChildPath 'TeamViewer/Logs' - $TVRoamingData = Join-Path -Path $RoamingAppData.ToString() -ChildPath 'TeamViewer' - $InstallationDirectory = Get-TeamViewerInstallationDirectory - - $TSCSearchDirectory = @{ - 'TeamViewer_Version15' = $InstallationDirectory - 'AppData\TeamViewer' = @($TVAppData; $TVRoamingData) - } - - return $TSCSearchDirectory -} - - - -function Get-TypeAndValueOfRegistryValue { - param ( - [Microsoft.Win32.RegistryKey]$RegKey, - [string]$ValueName - ) - - $valueKind = $RegKey.GetValueKind($ValueName) - $type = $valueKind - - if ($valueKind -eq 'DWord') { - $type = "=dword:" - $value = [Convert]::ToInt32($RegKey.GetValue($ValueName)).ToString('x') - } - elseif ($valueKind -eq 'Binary') { - $type = "=hex:" - $value = ($RegKey.GetValue($ValueName) | ForEach-Object { $_.ToString('x2') }) -join ',' - } - elseif ($valueKind -eq 'String') { - $type = "=" - $value = $RegKey.GetValue($ValueName).ToString() - } - elseif ($valueKind -eq 'MultiString') { - $type = "=hex(7):" - $value += ($RegKey.GetValue($ValueName) | ForEach-Object { - $_.ToCharArray() | ForEach-Object { [Convert]::ToInt32($_).ToString('X') + ',00' } - }) -join ',' - $value += ',00,00,' - if ($value.Length -gt 0) { - $value += '00,00' - } - } - else { - $type = "" - $value = $RegKey.GetValue($ValueName).ToString() - } - - return $type, $value -} - - - - -function Invoke-ExternalCommand { - param( - [Parameter(Mandatory = $true, Position = 0)] - [string] - $Command, - - [Parameter(ValueFromRemainingArguments = $true)] - [object[]] - $CommandArgs - ) - & $Command @CommandArgs -} - - - -function Invoke-TeamViewerRestMethod { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [uri] - $Uri, - - [Microsoft.PowerShell.Commands.WebRequestMethod] - $Method, - - [System.Collections.IDictionary] - $Headers, - - [System.Object] - $Body, - - [string] - $ContentType, - - [System.Management.Automation.PSCmdlet] - $WriteErrorTo - - ) - - if (-Not $Headers) { - $Headers = @{ } - $PSBoundParameters.Add('Headers', $Headers) | Out-Null - } - - if ($global:TeamViewerProxyUriSet) { - $Proxy = $global:TeamViewerProxyUriSet - } - elseif ([Environment]::GetEnvironmentVariable('TeamViewerProxyUri') ) { - $Proxy = [Environment]::GetEnvironmentVariable('TeamViewerProxyUri') - if ($global:TeamViewerProxyUriRemoved) { - $Proxy = $null - } - } - If ($Proxy) { - $PSBoundParameters.Add('Proxy', $Proxy) | Out-Null - } - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ApiToken) - $Headers['Authorization'] = "Bearer $([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr))" - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - $PSBoundParameters.Remove('ApiToken') | Out-Null - $PSBoundParameters.Remove('WriteErrorTo') | Out-Null - - $currentTlsSettings = [Net.ServicePointManager]::SecurityProtocol - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - - $currentProgressPreference = $ProgressPreference - $ProgressPreference = 'SilentlyContinue' - - - # Using `Invoke-WebRequest` instead of `Invoke-RestMethod`: - # There is a known issue for PUT and DELETE operations to hang on Windows Server 2012. - try { - - return ((Invoke-WebRequest -UseBasicParsing @PSBoundParameters).Content | ConvertFrom-Json) - } - catch { - $msg = $null - if ($PSVersionTable.PSVersion.Major -ge 6) { - $msg = $_.ErrorDetails.Message - } - elseif ($_.Exception.Response) { - $stream = $_.Exception.Response.GetResponseStream() - $reader = New-Object System.IO.StreamReader($stream) - $reader.BaseStream.Position = 0 - $msg = $reader.ReadToEnd() - } - $err = ($msg | ConvertTo-TeamViewerRestError) - if ($WriteErrorTo) { - $WriteErrorTo.WriteError(($err | ConvertTo-ErrorRecord)) - } - else { - throw $err - } - } - finally { - [Net.ServicePointManager]::SecurityProtocol = $currentTlsSettings - $ProgressPreference = $currentProgressPreference - } -} - - - -function Resolve-AssignmentErrorCode { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $exitCode - ) - Begin { - $exitCodeMessages = @{ - 0 = 'Operation successful' - 1 = 'Misspelled or used a wrong command' - 2 = 'Signature verification error' - 3 = 'TeamViewer is not installed' - 4 = 'The assignment configuration could not be verified against the TeamViewer Cloud.Try again later.' - 400 = 'Invalid assignment ID' - 401 = 'TeamViewer service not running' - 402 = 'Service Incompatible Version' - 403 = 'Check your internet connection' - 404 = 'Another assignment process running' - 405 = 'Timeout' - 406 = 'Failed due to unknown reasons' - 407 = 'Access denied. Ensure local administrator rights' - 408 = 'Denied by policy' - } - } - Process { - if ($exitCode) { - if ($exitCodeMessages.ContainsKey($exitCode)) { - Write-Output $exitCodeMessages[$exitCode] - } - else { - Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" - } - } - elseif ($exitCode -eq 0) { - Write-Output $exitCodeMessages[$exitCode] - } - } -} - - - -function Resolve-CustomizationErrorCode { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $exitCode - ) - Begin { - $exitCodeMessages = @{ - 0 = 'Operation successful' - 1 = 'Invalid command line arguments' - 500 = 'An internal error occurred. See TeamViewer log files for more details!' - 501 = 'The current user was denied access' - 502 = 'The download of the custom configuration timed out' - 503 = 'Invalid Module' - 504 = 'Restart of the GUI failed' - 505 = 'Custom configuration failed. See the TeamViewer log files for more details and check if the custom configuration id is still valid.' - 506 = 'Removal of custom configuration failed. See the TeamViewer log files for more details!' - } - } - Process { - if ($exitCode) { - if ($exitCodeMessages.ContainsKey($exitCode)) { - Write-Output $exitCodeMessages[$exitCode] - } - else { - Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" - } - } - elseif ($exitCode -eq 0) { - Write-Output $exitCodeMessages[$exitCode] - } - } -} - - - -function Resolve-TeamViewerContactId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Contact - ) - Process { - if ($Contact.PSObject.TypeNames -contains 'TeamViewerPS.Contact') { - return $Contact.Id - } - elseif ($Contact -is [string]) { - if ($Contact -notmatch 'c[0-9]+') { - throw "Invalid contact identifier '$Contact'. String must be a contact ID in the form 'c123456789'." - } - return $Contact - } - else { - throw "Invalid contact identifier '$Contact'. Must be either a [TeamViewerPS.Contact] or [string]." - } - } -} - - - -function Resolve-TeamViewerDeviceId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Device - ) - Process { - if ($Device.PSObject.TypeNames -contains 'TeamViewerPS.Device') { - return $Device.Id - } - elseif ($Device -is [string]) { - if ($Device -notmatch 'd[0-9]+') { - throw "Invalid device identifier '$Device'. String must be a device ID in the form 'd123456789'." - } - return $Device - } - else { - throw "Invalid device identifier '$Device'. Must be either a [TeamViewerPS.Device] or [string]." - } - } -} - - - -function Resolve-TeamViewerGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Group - ) - Process { - if ($Group.PSObject.TypeNames -contains 'TeamViewerPS.Group') { - return $Group.Id - } - elseif ($Group -is [string]) { - if ($Group -notmatch 'g[0-9]+') { - throw "Invalid group identifier '$Group'. String must be a group ID in the form 'g123456789'." - } - return $Group - } - else { - throw "Invalid group identifier '$Group'. Must be either a [TeamViewerPS.Group] or [string]." - } - } -} - - - -function Resolve-TeamViewerLanguage { - param( - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [object] - $InputObject - ) - Process { - $supportedLanguages = @( - 'bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'hr', 'hu', 'id', 'it', 'ja', - 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'th', 'tr', 'uk', - 'vi', 'zh_CN', 'zh_TW', 'auto') - - $language = $InputObject - if ($InputObject -is [cultureinfo]) { - $language = switch ($InputObject.Name) { - 'zh-CN' { 'zh_CN' } - 'zh-TW' { 'zh_TW' } - default { $InputObject.TwoLetterISOLanguageName } - } - } - - if ($supportedLanguages -notcontains $language) { - throw "Invalid culture '$language'. Supported languages are: $supportedLanguages" - } - - return $language - } -} - - - -function Resolve-TeamViewerManagedDeviceId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $ManagedDevice - ) - Process { - if ($ManagedDevice.PSObject.TypeNames -contains 'TeamViewerPS.ManagedDevice') { - return [guid]$ManagedDevice.Id - } - elseif ($ManagedDevice -is [string]) { - return [guid]$ManagedDevice - } - elseif ($ManagedDevice -is [guid]) { - return $ManagedDevice - } - else { - throw "Invalid managed device identifier '$ManagedDevice'. Must be either a [TeamViewerPS.ManagedDevice], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerManagedGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $ManagedGroup - ) - Process { - if ($ManagedGroup.PSObject.TypeNames -contains 'TeamViewerPS.ManagedGroup') { - return [guid]$ManagedGroup.Id - } - elseif ($ManagedGroup -is [string]) { - return [guid]$ManagedGroup - } - elseif ($ManagedGroup -is [guid]) { - return $ManagedGroup - } - else { - throw "Invalid managed group identifier '$ManagedGroup'. Must be either a [TeamViewerPS.ManagedGroup], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerManagerId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Manager - ) - Process { - if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { - return [guid]$Manager.Id - } - elseif ($Manager -is [string]) { - return [guid]$Manager - } - elseif ($Manager -is [guid]) { - return $Manager - } - else { - throw "Invalid manager identifier '$Manager'. Must be either a [TeamViewerPS.Manager], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerPolicyId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Policy, - - [Parameter()] - [switch] - $AllowNone, - - [Parameter()] - [switch] - $AllowInherit - ) - Process { - if ($Policy.PSObject.TypeNames -contains 'TeamViewerPS.Policy') { - return [guid]$Policy.Id - } - elseif ($Policy -is [string]) { - if ($Policy -eq 'none' -And $AllowNone) { - return 'none' - } - elseif ($Policy -eq 'inherit' -And $AllowInherit) { - return 'inherit' - } - else { - return [guid]$Policy - } - } - elseif ($Policy -is [guid]) { - return $Policy - } - else { - throw "Invalid policy identifier '$Policy'. Must be either a [TeamViewerPS.Policy], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerSsoDomainId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Domain - ) - Process { - if ($Domain.PSObject.TypeNames -contains 'TeamViewerPS.SsoDomain') { - return [guid]$Domain.Id - } - elseif ($Domain -is [string]) { - return [guid]$Domain - } - elseif ($Domain -is [guid]) { - return $Domain - } - else { - throw "Invalid SSO domain identifier '$Domain'. Must be either a [TeamViewerPS.SsoDomain], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerUserEmail { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $false)] - [object] - $User - ) - Process { - if (!$User) { - return $null - } - elseif ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { - return $User.Email - } - elseif ($User -is [string]) { - return $User - } - else { - throw "Invalid user email '$User'. Must be either a [TeamViewerPS.User] or [string]." - } - } -} - - - -function Resolve-TeamViewerUserGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserGroup - ) - Process { - if ($UserGroup.PSObject.TypeNames -contains 'TeamViewerPS.UserGroup') { - return [UInt64]$UserGroup.Id - } - elseif ($UserGroup -is [string]) { - return [UInt64]$UserGroup - } - elseif ($UserGroup -is [UInt64] -or $UserGroup -is [Int64] -or $UserGroup -is [int]) { - return [UInt64]$UserGroup - } - else { - throw "Invalid user group identifier '$UserGroup'. Must be either a [TeamViewerPS.UserGroup], [UInt64], [Int64] or [string]." - } - } -} - - - -function Resolve-TeamViewerUserGroupMemberMemberId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserGroupMember - ) - Process { - if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { - return $UserGroupMember.AccountId - } - elseif ($UserGroupMember -match 'u[0-9]+') { - return $UserGroupMember - } - elseif ($UserGroupMember -is [string]) { - return [int]$UserGroupMember - } - elseif ($UserGroupMember -is [int]) { - return $UserGroupMember - } - else { - throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." - } - } -} - - - -function Resolve-TeamViewerUserId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $User - ) - Process { - if ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { - return $User.Id - } - elseif ($User -is [string]) { - if ($User -notmatch 'u[0-9]+') { - throw "Invalid user identifier '$User'. String must be a user ID in the form 'u123456789'." - } - return $User - } - else { - throw "Invalid user identifier '$User'. Must be either a [TeamViewerPS.User] or [string]." - } - } -} - - - - -function Resolve-TeamViewerUserRoleId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserRole - ) - Process { - if ($UserRole.PSObject.TypeNames -contains 'TeamViewerPS.UserRole') { - return [string]$UserRole.RoleID - } - elseif ($UserRole -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { - return [string]$UserRole - } - else { - throw "Invalid role group identifier '$UserRole'. Must be either a [TeamViewerPS.UserRole] or [UUID] " - } - } -} - - - -$hasTestNetConnection = [bool](Get-Command Test-NetConnection -ErrorAction SilentlyContinue) -$hasTestConnection = [bool](Get-Command Test-Connection -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge 5.1 }) - -function Test-TcpConnection { - param( - [Parameter(Mandatory = $true)] - [string] - $Hostname, - - [Parameter(Mandatory = $true)] - [int] - $Port - ) - - if (-Not $hasTestNetConnection -And -Not $hasTestConnection) { - throw "No suitable cmdlet found for testing the TeamViewer network connectivity." - } - - $oldProgressPreference = $global:ProgressPreference - $global:ProgressPreference = 'SilentlyContinue' - - if ($hasTestNetConnection) { - Test-NetConnection -ComputerName $Hostname -Port $Port -InformationLevel Quiet -WarningAction SilentlyContinue - } - elseif ($hasTestConnection) { - Test-Connection -TargetName $Hostname -TcpPort $Port -Quiet -WarningAction SilentlyContinue - } - else { - $false - } - - $global:ProgressPreference = $oldProgressPreference -} - - - -function Test-TeamViewer32on64 { - if (![Environment]::Is64BitOperatingSystem) { - return $false - } - $registryKey = Get-TeamViewerRegKeyPath -Variant WOW6432 - if (!(Test-Path $registryKey)) { - return $false - } - try { - $installationDirectory = (Get-Item $registryKey).GetValue('InstallationDirectory') - $binaryPath = Join-Path $installationDirectory 'TeamViewer.exe' - return Test-Path $binaryPath - } - catch { - return $false - } -} - - - -function Add-TeamViewerAssignment { - param( - [Parameter(Mandatory = $true)] - [object] - $AssignmentId, - - [string] - $DeviceAlias, - - [int] - $Retries - ) - - - if (Test-TeamViewerInstallation) { - $OS = Get-OperatingSystem - $CurrentDirectory = Get-Location - $installationDirectory = Get-TeamViewerInstallationDirectory - Set-Location $installationDirectory - $CurrentVersion = Get-TeamViewerVersion - $VersionTable = $CurrentVersion.split('.') - if ($OS -eq 'Windows') { - $cmd = "assignment --id $AssignmentId" - $FilePath = 'TeamViewer.exe' - } - elseif ($OS -eq 'Linux') { - $cmd = "teamviewer assignment --id $AssignmentId" - $FilePath = 'sudo' - } - - if ($DeviceAlias) { - if (($VersionTable[0] -eq 15 -and $VersionTable[1] -ge 44) -or $VersionTable[0] -gt 15) { - $cmd += " --device-alias=$DeviceAlias" - } - else { - Write-Error "Current TeamViewer Version: $CurrentVersion does not support the usage of alias. Please update to the latest version." - Set-Location $CurrentDirectory - exit - } - } - if ($Retries) { - $cmd += " --retries=$Retries" - } - $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-AssignmentErrorCode - Set-Location $CurrentDirectory - } - else { - Write-Output 'TeamViewer is not installed.' - } -} - - - - - -Function Add-TeamViewerCustomization { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true, ParameterSetName = 'ById')] - [object] - $Id, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByPath')] - [object] - $Path, - - [switch] - $RestartGUI, - - [switch] - $RemoveExisting - ) - - if (Get-OperatingSystem -eq 'Windows') { - if (Test-TeamViewerInstallation) { - $installationDirectory = Get-TeamViewerInstallationDirectory - $currentDirectory = Get-Location - Set-Location $installationDirectory - $cmd = 'customize' - if ($Id) { - $cmd += " --id $Id" - } - elseif ($Path) { - $cmd += " --path $Path" - } - if ($RemoveExisting) { - $cmd += ' --remove' - } - if ($RestartGUI) { - $cmd += ' --restart-gui' - } - $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-CustomizationErrorCode - Set-Location $currentDirectory - } - else { - Write-Error 'TeamViewer is not installed' - } - } - else { - Write-Error 'Customization is currently supported only on Windows.' - } -} - - - -function Add-TeamViewerManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices" - - $body = @{ - id = $deviceId - } - - if ($PSCmdlet.ShouldProcess($deviceId, "Add device to managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Add-TeamViewerManager { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByAccountId')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] - [string] - $AccountId, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagerId } )] - [Alias("ManagerId")] - [object] - $Manager, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [object] - $User, - - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId })] - [Alias('UserGroupId')] - [object] - $UserGroup, - - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter()] - [AllowEmptyCollection()] - [string[]] - $Permissions - ) - - $resourceUri = $null - switch -Wildcard ($PSCmdlet.ParameterSetName) { - 'Device*' { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" - $processMessage = "Add manager to managed device" - } - 'Group*' { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" - $processMessage = "Add manager to managed group" - } - } - - $body = @{} - switch -Wildcard ($PSCmdlet.ParameterSetName) { - '*ByAccountId' { - $body["accountId"] = $AccountId.TrimStart('u') - } - '*ByManagerId' { - $body["id"] = $Manager | Resolve-TeamViewerManagerId - } - '*ByUserObject' { - $body["accountId"] = ( $User | Resolve-TeamViewerUserId ).TrimStart('u') - } - '*ByUserGroupId' { - $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId - } - } - - if ($Permissions) { - $body["permissions"] = @($Permissions) - } - else { - $body["permissions"] = @() - } - - if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @($body)))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Add-TeamViewerRoleToAccount { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [object] - $UserRoleId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [Alias('Id', 'UserIds')] - [string[]] - $Accounts - ) - - Begin { - $id = $UserRoleId | Resolve-TeamViewerUserRoleId - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" - $AccountsToAdd = @() - $body = @{ - UserIds = @() - UserRoleId = $id - } - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - } - - - Process { - if ($PSCmdlet.ShouldProcess($Accounts, 'Assign Account to Role')) { - if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { - $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } - } - foreach ($Account in $Accounts) { - $AccountsToAdd += $Account - $body.UserIds = @($AccountsToAdd) - } - } - if ($AccountsToAdd.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $AccountsToAdd = @() - } - } - End { - if ($AccountsToAdd.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - - -function Add-TeamViewerRoleToUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRoleId')] - [object] - $UserRole, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup - ) - - Begin { - $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" - $body = @{ - UserRoleId = $RoleId - UserGroupId = $UserGroup - - } - } - - - Process { - if ($PSCmdlet.ShouldProcess($UserGroup, 'Assign Role to User Group')) { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - } -} - - - -function Add-TeamViewerSsoExclusion { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] - [Alias("Domain")] - [object] - $DomainId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [string[]] - $Email - ) - Begin { - $id = $DomainId | Resolve-TeamViewerSsoDomainId - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" - $emailsToAdd = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-RequestInternal { - $body = @{ - emails = @($emailsToAdd) - } - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } - Process { - if ($PSCmdlet.ShouldProcess($Email, "Add SSO exclusion")) { - $emailsToAdd += $Email - } - if ($emailsToAdd.Length -eq 100) { - Invoke-RequestInternal - $emailsToAdd = @() - } - } - End { - if ($emailsToAdd.Length -gt 0) { - Invoke-RequestInternal - } - } -} - - - -function Add-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [object[]] - [Alias('UserGroupMemberId')] - [Alias('UserGroupMember')] - [Alias('MemberId')] - [Alias('UserId')] - [Alias('User')] - $Member - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToAdd = @() - $body = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) - } - } - - Process { - # when members are provided as pipeline input, each member is provided as a separate statement, - # thus the members should be combined into one array in order to send a single request. - if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { - if ($Member -notmatch 'u[0-9]+') { - ForEach-Object { - $Member = [int[]]$Member - } - } - else { - ForEach-Object { - $Member = [int[]]$Member.trim('u') - } - } - if ($Member -isnot [array]) { - $membersToAdd = @([UInt32]$Member) - } - else { - $membersToAdd += [UInt32[]]$Member - } - $payload = $membersToAdd -join ', ' - $body = "[$payload]" - } - - # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` - # in order to accept more members - if ($membersToAdd.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $membersToAdd = @() - } - } - - End { - # A request needs to be sent if there were less than 100 members - if ($membersToAdd.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - -function Connect-TeamViewerApi { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - if (Invoke-TeamViewerPing -ApiToken $ApiToken) { - $global:PSDefaultParameterValues["*-Teamviewer*:ApiToken"] = $ApiToken - } -} - - -function Disconnect-TeamViewerApi { - $global:PSDefaultParameterValues.Remove("*-Teamviewer*:ApiToken") -} - - -function Export-TeamViewerSystemInformation { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $TargetDirectory - ) - Process { - if (Test-TeamViewerInstallation ) { - if (Get-OperatingSystem -eq 'Windows') { - $Temp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.Guid]::NewGuid().ToString()) - $CurrentDirectory = Get-Location - $Temp | Get-TSCDirectoryFile - $Temp | Get-InstalledSoftware - $Temp | Get-IpConfig - $Temp | Get-MSInfo32 - $Temp | Get-HostFile - $Temp | Get-NSLookUpData - $Temp | Get-RouteTable - $Temp | Get-RegistryPath - $ClientID = Get-ClientId - $ZipFileName = 'TV_SC_' + $ClientID + '_WINPS.zip' - $ZipPath = Join-Path -Path "$Temp\Data" -ChildPath $ZipFileName - Compress-Archive -Path $Temp\* -DestinationPath $ZipPath -Force - if ($TargetDirectory -and (Test-Path $TargetDirectory)) { - Copy-Item -Path $ZipPath -Destination $TargetDirectory -Force - } - else { - Copy-Item -Path $ZipPath -Destination $CurrentDirectory -Force - } - } - else { - Write-Error 'Currently this functionality is supported only on Windows.' - } - } - else { - Write-Error 'TeamViewer is not installed.' - } - } -} - - - -function Get-TeamViewerAccount { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/account" - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerAccount) -} - - - -function Get-TeamViewerConnectionReport { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $false)] - [string] - $UserName, - - [Parameter(Mandatory = $false)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("User")] - [object] - $UserId, - - [Parameter(Mandatory = $false)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("Group")] - [object] - $GroupId, - - [Parameter(Mandatory = $false)] - [string] - $DeviceName, - - [Parameter(Mandatory = $false)] - [int] - $DeviceId, - - [Parameter(Mandatory = $false)] - [switch] - $WithSessionCode, - - [Parameter(Mandatory = $false)] - [switch] - $WithoutSessionCode, - - [Parameter(Mandatory = $false)] - [string] - $SessionCode, - - [Parameter(Mandatory = $false)] - [TeamViewerConnectionReportSessionType] - $SupportSessionType, - - [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] - [DateTime] - $StartDate, - - [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [DateTime] - $EndDate = (Get-Date), - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 12)] - [int] - $Months, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 31)] - [int] - $Days, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 24)] - [int] - $Hours, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 60)] - [int] - $Minutes, - - [Parameter(Mandatory = $false)] - [ValidateRange(1, [int]::MaxValue)] - [int] - $Limit - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/reports/connections"; - - $parameters = @{} - - if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { - $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) - } - if ($StartDate -And $EndDate -And $StartDate -lt $EndDate) { - $parameters.from_date = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - $parameters.to_date = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - } - - if ($UserName) { - $parameters.username = $UserName - } - - if ($UserId) { - $parameters.userid = $UserId | Resolve-TeamViewerUserId - } - - if ($DeviceName) { - $parameters.devicename = $DeviceName - } - - if ($DeviceId) { - $parameters.deviceid = $DeviceId - } - - if ($GroupId) { - $parameters.groupid = $GroupId | Resolve-TeamViewerGroupId - } - - if ($WithSessionCode -And !$WithoutSessionCode) { - $parameters.has_code = $true - } - elseif ($WithoutSessionCode -And !$WithSessionCode) { - $parameters.has_code = $false - } - - if ($SessionCode) { - $parameters.session_code = $SessionCode - } - - if ($SupportSessionType) { - $parameters.support_session_type = [int]$SupportSessionType - } - - $remaining = $Limit - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $results = ($response.records | ConvertTo-TeamViewerConnectionReport) - if ($Limit) { - Write-Output ($results | Select-Object -First $remaining) - $remaining = $remaining - @($results).Count - } - else { - Write-Output $results - } - $parameters.offset_id = $response.next_offset - } while ($parameters.offset_id -And (!$Limit -Or $remaining -gt 0)) -} - - - -function Get-TeamViewerContact { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByContactId")] - [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] - [Alias("ContactId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [Alias("PartialName")] - [string] - $Name, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateSet('Online', 'Busy', 'Away', 'Offline')] - [string] - $FilterOnlineState, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/contacts"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByContactId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($Name) { - $parameters['name'] = $Name - } - if ($FilterOnlineState) { - $parameters['online_state'] = $FilterOnlineState.ToLower() - } - if ($Group) { - $groupId = $Group | Resolve-TeamViewerGroupId - $parameters['groupid'] = $groupId - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($response.contacts | ConvertTo-TeamViewerContact) -} - - - -function Get-TeamViewerCustomModuleId { - - if (Test-TeamViewerinstallation) { - $fileName = 'TeamViewer.json' - $installationDirectory = Get-TeamViewerInstallationDirectory - $filePath = Join-Path -Path $installationDirectory -ChildPath $fileName - if (Test-Path -Path $filePath) { - $jsonContent = Get-Content -Path $FilePath -Raw - $jsonObject = ConvertFrom-Json $jsonContent - if ($jsonObject.id) { - return $jsonObject.id - } - } - else { - Write-Error 'Custom module Id cannot be found. Check if customization is applied.' - } - } - else { - Write-Error 'TeamViewer is not installed' - } - -} - - - -function Get-TeamViewerDevice { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] - [Alias("DeviceId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [int] - $TeamViewerId, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateSet('Online', 'Busy', 'Away', 'Offline')] - [string] - $FilterOnlineState, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/devices"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($TeamViewerId) { - $parameters['remotecontrol_id'] = "r$TeamViewerId" - } - if ($FilterOnlineState) { - $parameters['online_state'] = $FilterOnlineState.ToLower() - } - if ($Group) { - $groupId = $Group | Resolve-TeamViewerGroupId - $parameters['groupid'] = $groupId - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($response.devices | ConvertTo-TeamViewerDevice) -} - - - -function Get-TeamViewerEventLog { - [CmdletBinding(DefaultParameterSetName = "RelativeDates")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] - [DateTime] - $StartDate, - - [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [DateTime] - $EndDate = (Get-Date), - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 12)] - [int] - $Months, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 31)] - [int] - $Days, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 24)] - [int] - $Hours, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 60)] - [int] - $Minutes, - - [Parameter(Mandatory = $false)] - [int] - $Limit, - - [Parameter(Mandatory = $false)] - [ArgumentCompleter( { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - @( - 'AddRemoteWorkerDevice', - 'ChangedDisabledRemoteInput', - 'ChangedShowBlackScreen', - 'CompanyAddressBookDisabled', - 'CompanyAddressBookEnabled', - 'CompanyAddressBookMembersHid', - 'CompanyAddressBookMembersUnhid' - 'ConditionalAccessBlockMeetingStateChanged', - 'ConditionalAccessDirectoryGroupAdded', - 'ConditionalAccessDirectoryGroupDeleted', - 'ConditionalAccessDirectoryGroupMembersAdded', - 'ConditionalAccessDirectoryGroupMembersDeleted', - 'ConditionalAccessRuleAdded', - 'ConditionalAccessRuleDeleted', - 'ConditionalAccessRuleModified', - 'ConditionalAccessRuleVerificationStateChanged', - 'CreateCustomHost', - 'DeleteCustomHost', - 'EditOwnProfile', - 'EditTFAUsage', - 'EditUserPermissions', - 'EditUserProperties', - 'EmailConfirmed', - 'EndedRecording', - 'EndedSession', - 'GroupAdded', - 'GroupDeleted', - 'GroupShared', - 'GroupUpdated', - 'IncomingSession', - 'JoinCompany', - 'JoinedSession', - 'LeftSession', - 'ParticipantJoinedSession', - 'ParticipantLeftSession', - 'PausedRecording', - 'PolicyAdded', - 'PolicyDeleted', - 'PolicyUpdated', - 'ReceivedDisabledLocalInput', - 'ReceivedFile', - 'ReceivedShowBlackScreen', - 'RemoveRemoteWorkerDevice', - 'ResumedRecording', - 'ScriptTokenAdded', - 'ScriptTokenDeleted', - 'ScriptTokenUpdated', - 'SentFile', - 'StartedRecording', - 'StartedSession', - 'SwitchedSides', - 'UpdateCustomHost', - 'UserCreated', - 'UserDeleted', - 'UserGroupCreated', - 'UserGroupDeleted', - 'UserGroupMembersAdded', - 'UserGroupMembersRemoved', - 'UserGroupUpdated', - 'UserRemovedFromCompany' - ) | Where-Object { $_ -like "$wordToComplete*" } - } )] - [string[]] - $EventNames, - - [Parameter(Mandatory = $false)] - [ArgumentCompleter( { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - @( - "CompanyAddressBook", - "CompanyAdministration", - "ConditionalAccess", - "CustomModules", - "GroupManagement", - "LicenseManagement", - "Policy", - "Session", - "UserGroups", - "UserProfile" - ) | Where-Object { $_ -like "$wordToComplete*" } - })] - [string[]] - $EventTypes, - - [Parameter(Mandatory = $false)] - [ValidateScript( { $_ | Resolve-TeamViewerUserEmail } )] - [Alias("Users")] - [object[]] - $AccountEmails, - - [Parameter(Mandatory = $false)] - [string] - $AffectedItem, - - [Parameter(Mandatory = $false)] - [Alias("RemoteControlSession")] - [guid] - $RemoteControlSessionId - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/EventLogging"; - - $Limit = if ($Limit -lt 0) { $null } else { $Limit } - - if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { - $Hours = if (!$Months -And !$Days -And !$Hours -And !$Minutes) { 1 } else { $Hours } - $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) - } - - $parameters = @{ - StartDate = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - EndDate = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - } - - if ($EventNames) { - $parameters.EventNames = $EventNames - } - if ($EventTypes) { - $parameters.EventTypes = $EventTypes - } - if ($AccountEmails) { - $parameters.AccountEmails = @($AccountEmails | Resolve-TeamViewerUserEmail) - } - if ($AffectedItem) { - $parameters.AffectedItem = $AffectedItem - } - if ($RemoteControlSessionId) { - $parameters.RCSessionGuid = $RemoteControlSessionId - } - - $remaining = $Limit - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($parameters | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $results = ($response.AuditEvents | ConvertTo-TeamViewerAuditEvent) - if ($Limit) { - Write-Output ($results | Select-Object -First $remaining) - $remaining = $remaining - @($results).Count - } - else { - Write-Output $results - } - $parameters.ContinuationToken = $response.ContinuationToken - } while ($parameters.ContinuationToken -And (!$Limit -Or $remaining -gt 0)) -} - - - -function Get-TeamViewerGroup { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByGroupId")] - [Alias("GroupId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [Alias("PartialName")] - [string] - $Name, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateSet('OnlyShared', 'OnlyNotShared')] - [string] - $FilterShared - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/groups"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByGroupId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($Name) { - $parameters['name'] = $Name - } - switch ($FilterShared) { - 'OnlyShared' { $parameters['shared'] = $true } - 'OnlyNotShared' { $parameters['shared'] = $false } - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { - Write-Output ($response | ConvertTo-TeamViewerGroup) - } - else { - Write-Output ($response.groups | ConvertTo-TeamViewerGroup) - } -} - - - -function Get-TeamViewerId { - if (Test-TeamViewerInstallation) { - switch (Get-OperatingSystem) { - 'Windows' { - Write-Output (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'ClientID') - } - 'Linux' { - Write-Output (Get-TeamViewerLinuxGlobalConfig -Name 'ClientID') - } - } - } -} - - - -function Get-TeamViewerInstallationDirectory { - switch (Get-OperatingSystem) { - 'Windows' { - $regKey = Get-TeamViewerRegKeyPath - $installationDirectory = if (Test-Path $regKey) { - (Get-Item $regKey).GetValue('InstallationDirectory') - } - if ( - $installationDirectory -And ` - (Test-Path "$installationDirectory/TeamViewer.exe") - ) { - return $installationDirectory - } - } - 'Linux' { - if ( - (Test-Path '/opt/teamviewer/tv_bin/TeamViewer') - ) { - return '/opt/teamviewer/tv_bin/' - } - } - default { - Write-Error 'TeamViewer not installed' - } - } -} - - - - -function Get-TeamViewerLogFilePath { - param( - [switch] - $OpenFile - ) - - if (Test-TeamViewerInstallation) { - if (Get-OperatingSystem -eq 'Windows') { - $SearchDirectories = Get-TSCSearchDirectory - $LogFiles = New-Object System.Collections.ArrayList - foreach ($Name in $SearchDirectories.Keys) { - $SearchDirectory = $SearchDirectories[$Name] - foreach ($Folder in $SearchDirectory) { - if (Test-Path -Path $Folder) { - $files = Get-ChildItem -Path $Folder -File -Recurse - foreach ($file in $files) { - if ($file.Name.EndsWith('.log')) { - $LogFiles.add($file.FullName) | Out-Null - } - } - } - } - } - - if ($OpenFile) { - $LogFile = $host.ui.PromptForChoice('Select file', 'Choose file:', ` - @($LogFiles), 0) - Invoke-Item -Path $LogFiles[$LogFile] - } - else { - return $LogFiles - } - } - } - else { - Write-Error 'TeamViewer is not installed.' - } -} - - - -function Get-TeamViewerManagedDevice { - [CmdletBinding(DefaultParameterSetName = "List")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [Alias("Device")] - [guid] - $Id, - - [Parameter(Mandatory = $true, ParameterSetName = "ListGroup")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(ParameterSetName = "ListGroup")] - [switch] - $Pending - ) - - # default is 'List': - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices"; - $parameters = @{ } - $isListOperation = $true - - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - $resourceUri += "/$Id" - $parameters = $null - $isListOperation = $false - } - 'ListGroup' { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/$(if ($Pending) { "pending-" })devices" - } - } - - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByDeviceId') { - Write-Output ($response | ConvertTo-TeamViewerManagedDevice) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerManagedDevice) - } - } while ($isListOperation -And $parameters.paginationToken) -} - - - -function Get-TeamViewerManagedGroup { - [CmdletBinding(DefaultParameterSetName = "List")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByGroupId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } ) ] - [Alias("GroupId")] - [guid] - $Id, - - [Parameter(ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByGroupId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'ByDeviceId' { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/groups" - } - } - - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { - Write-Output ($response | ConvertTo-TeamViewerManagedGroup) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerManagedGroup) - } - } while ($PsCmdlet.ParameterSetName -In @('List', 'ByDeviceId') ` - -And $parameters.paginationToken) -} - - - -function Get-TeamViewerManagementId { - if (Test-TeamViewerInstallation) { - switch (Get-OperatingSystem) { - 'Windows' { - $regKeyPath = Join-Path (Get-TeamViewerRegKeyPath) 'DeviceManagementV2' - $regKey = if (Test-Path -LiteralPath $regKeyPath) { Get-Item -Path $regKeyPath } - if ($regKey) { - $unmanaged = [bool]($regKey.GetValue('Unmanaged')) - $managementId = $regKey.GetValue('ManagementId') - } - } - 'Linux' { - $unmanaged = [bool](Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\Unmanaged') - $managementId = Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\ManagementId' - } - } - if (!$unmanaged -And $managementId) { - Write-Output ([guid]$managementId) - } - } -} - - - -function Get-TeamViewerManager { - [CmdletBinding(DefaultParameterSetName = "ByDeviceId")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true, ParameterSetName = "ByGroupId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $resourceUri = $null - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" - } - 'ByGroupId' { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - Write-Output ($response.resources | ConvertTo-TeamViewerManager -DeviceId $deviceId) - } - 'ByGroupId' { - Write-Output ($response.resources | ConvertTo-TeamViewerManager -GroupId $groupId) - } - } -} - - - -function Get-TeamViewerPolicy { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByPolicyId")] - [Alias("PolicyId")] - [guid] - $Id - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByPolicyId' { - $resourceUri += "/$Id" - $parameters = $null - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($response.policies | ConvertTo-TeamViewerPolicy) -} - - - - -function Get-TeamViewerRoleAssignmentToAccount { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [string] - $UserRoleId - ) - - - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$UserRoleId" - $parameters = $null - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($response.ContinuationToken) { - $resourceUri += '&continuationToken=' + $response.ContinuationToken - } - Write-Output ($response.AssignedToUsers | ConvertTo-TeamViewerRoleAssignedUser ) - }while ($response.ContinuationToken) -} - - - -function Get-TeamViewerRoleAssignmentToUserGroup { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript({ $_ | Resolve-TeamviewerUserRoleId })] - [Alias('UserRole')] - [string] - $UserRoleId - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$UserRoleId" - $parameters = $null - } - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($response.ContinuationToken) { - $resourceUri += "&continuationToken=" + $response.ContinuationToken - } - Write-Output ($response.AssignedToGroups | ConvertTo-TeamViewerRoleAssignedUserGroup ) - }while ($response.ContinuationToken) - } -} - - - -function Get-TeamViewerService { - switch (Get-OperatingSystem) { - 'Windows' { - Get-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon status - } - } -} - - - -function Get-TeamViewerSsoDomain { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain"; - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response.domains | ConvertTo-TeamViewerSsoDomain) -} - - - -function Get-TeamViewerSsoExclusion { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] - [Alias("Domain")] - [object] - $DomainId - ) - - $id = $DomainId | Resolve-TeamViewerSsoDomainId - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion"; - $parameters = @{ } - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output $response.emails - $parameters.ct = $response.continuation_token - } while ($parameters.ct) -} - - - -function Get-TeamViewerUser { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByUserId")] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [Alias("PartialName")] - [string] - $Name, - - [Parameter(ParameterSetName = "FilteredList")] - [string[]] - $Email, - - [Parameter(ParameterSetName = "FilteredList")] - [string[]] - $Permissions, - - [Parameter()] - [ValidateSet("All", "Minimal")] - $PropertiesToLoad = "All" - ) - - $parameters = @{ } - switch ($PropertiesToLoad) { - "All" { $parameters.full_list = $true } - "Minimal" { } - } - - $resourceUri = "$(Get-TeamViewerApiUri)/users" - - switch ($PsCmdlet.ParameterSetName) { - "ByUserId" { - $resourceUri += "/$Id" - $parameters = $null - } - "FilteredList" { - if ($Name) { - $parameters['name'] = $Name - } - if ($Email) { - $parameters['email'] = ($Email -join ',') - } - if ($Permissions) { - $parameters['permissions'] = ($Permissions -join ',') - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq "ByUserId") { - Write-Output ($response | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) - } - else { - Write-Output ($response.users | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) - } -} - - - -function Get-TeamViewerUserGroup { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" - $parameters = @{ } - $isListOperation = $true - - if ($UserGroup) { - $GroupId = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri += "/$GroupId" - $parameters = $null - $isListOperation = $false - } - } - - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($UserGroup) { - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerUserGroup) - } - } while ($isListOperation -And $parameters.paginationToken) - } -} - - - -function Get-TeamViewerUserGroupMember { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $parameters = @{ } - } - - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerUserGroupMember) - } while ($parameters.paginationToken) - } -} - - - -function Get-TeamViewerUserRole { - [CmdletBinding(DefaultParameterSetName = '')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - Begin{ - $parameters = @{ } - $resourceUri = "$(Get-TeamViewerApiUri)/userroles" - } - -Process{ - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response.Roles | ConvertTo-TeamViewerUserRole ) -} -} - - - -function Get-TeamViewerVersion { - if (Test-TeamViewerInstallation) { - switch (Get-OperatingSystem) { - 'Windows' { - return (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'Version') - } - 'Linux' { - return (Get-TeamViewerLinuxGlobalConfig -Name 'Version') - } - } - } -} - - - -function Invoke-TeamViewerPackageDownload { - Param( - [Parameter()] - [ValidateSet('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')] - [ValidateScript( { - if (($_ -ne 'Full') -And ((Get-OperatingSystem) -ne 'Windows')) { - $PSCmdlet.ThrowTerminatingError( - ("PackageType parameter is only supported on Windows platforms" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $true - })] - [string] - $PackageType, - - [Parameter()] - [ValidateScript( { - if ((Get-OperatingSystem) -ne 'Windows') { - $PSCmdlet.ThrowTerminatingError( - ("MajorVersion parameter is only supported on Windows platforms" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if($PackageType -eq 'MSI32' -or 'MSI64' ){ - $PSCmdlet.ThrowTerminatingError( - ("MajorVersion parameter is not supported for MSI packages" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if ($_ -lt 14) { - $PSCmdlet.ThrowTerminatingError( - ("Unsupported TeamViewer version $_" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $true - } )] - [int] - $MajorVersion, - - [Parameter()] - [string] - $TargetDirectory = (Get-Location).Path, - - [Parameter()] - [switch] - $Force - ) - - if ((-not $PackageType) -And ((Get-OperatingSystem) -eq 'Windows')) { - $Package = $host.ui.PromptForChoice('Select Package Type', 'Choose a package type:', ` - @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit'), 0) - $PackageType = @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')[$Package] - } - - $additionalPath = '' - switch (Get-OperatingSystem) { - 'Windows' { - $filename = switch ($PackageType) { - 'Full' { 'TeamViewer_Setup.exe' } - 'MSI32' { 'TeamViewer_MSI32.zip' } - 'MSI64' { 'TeamViewer_MSI64.zip' } - 'Host' { 'TeamViewer_Host_Setup.exe' } - 'Portable' { 'TeamViewerPortable.zip' } - 'QuickJoin' { 'TeamViewerQJ.exe' } - 'QuickSupport' { 'TeamViewerQS.exe' } - 'Full64Bit' { 'TeamViewer_Setup_x64.exe' } - } - if ($MajorVersion) { - $additionalPath = "/version_$($MajorVersion)x" - } - if(($PackageType -eq 'MSI32' -or 'MSI64' )){ - $additionalPath = '/version_15x' - } - } - 'Linux' { - $releaseInfo = (Get-Content /etc/*-release) - $filename = switch -Regex ($releaseInfo) { - 'debian|ubuntu' { - $platform = if ([Environment]::Is64BitOperatingSystem) { 'amd64' } else { 'i386' } - "teamviewer_$platform.deb" - } - 'centos|rhel|fedora' { - $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } - "teamviewer.$platform.rpm" - } - 'suse|opensuse' { - $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } - "teamviewer-suse.$platform.rpm" - } - } - $filename = $filename | Select-Object -First 1 - $additionalPath = '/linux' - } - } - - $downloadUrl = "https://dl.teamviewer.com/download$additionalPath/$filename" - $targetFile = Join-Path $TargetDirectory $filename - - if ((Test-Path $targetFile) -And -Not $Force -And ` - -Not $PSCmdlet.ShouldContinue("File $targetFile already exists. Override?", "Override existing file?")) { - return - } - - Write-Verbose "Downloading $downloadUrl to $targetFile" - $client = New-Object System.Net.WebClient - $client.DownloadFile($downloadUrl, $targetFile) - Write-Output $targetFile -} - - - -function Invoke-TeamViewerPing { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/ping" - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output $result.token_valid -} - - - -function New-TeamViewerContact { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter()] - [switch] - $Invite - ) - - $body = @{ - email = $Email - groupid = $Group | Resolve-TeamViewerGroupId - } - if ($Invite) { - $body['invite'] = $true - } - - $resourceUri = "$(Get-TeamViewerApiUri)/contacts" - if ($PSCmdlet.ShouldProcess($Email, "Create contact")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response | ConvertTo-TeamViewerContact) - Write-Output $result - } -} - - - -function New-TeamViewerDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [int] - $TeamViewerId, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter()] - [Alias("Alias")] - [string] - $Name, - - [Parameter()] - [string] - $Description, - - [Parameter()] - [securestring] - $Password - ) - - $body = @{ - remotecontrol_id = "r$TeamViewerId" - groupid = $Group | Resolve-TeamViewerGroupId - } - - if ($Name) { - $body['alias'] = $Name - } - if ($Description) { - $body['description'] = $Description - } - if ($Password) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - - $resourceUri = "$(Get-TeamViewerApiUri)/devices" - if ($PSCmdlet.ShouldProcess($TeamViewerId, "Create device entry")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response | ConvertTo-TeamViewerDevice) - Write-Output $result - } -} - - - -function New-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias("PolicyId")] - [object] - $Policy - ) - - $body = @{ name = $Name } - if ($Policy) { - $body["policy_id"] = $Policy | Resolve-TeamViewerPolicyId - } - - $resourceUri = "$(Get-TeamViewerApiUri)/groups" - if ($PSCmdlet.ShouldProcess($Name, "Create group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerGroup) - } -} - - - -function New-TeamViewerManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name - ) - - $body = @{ name = $Name } - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" - if ($PSCmdlet.ShouldProcess($Name, "Create managed group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerManagedGroup) - } -} - - - -function New-TeamViewerPolicy { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name, - - [Parameter()] - [AllowEmptyCollection()] - [object[]] - $Settings, - - [Parameter()] - [switch] - $DefaultPolicy = $False - ) - - $body = @{ - name = $Name - default = [boolean]$DefaultPolicy - settings = @() - } - - if ($Settings) { - $body.settings = @($Settings) - } - - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies" - if ($PSCmdlet.ShouldProcess($Name, "Create policy")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function New-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "WithPassword")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(Mandatory = $true)] - [Alias('DisplayName')] - [string] - $Name, - - [Parameter(Mandatory = $true, ParameterSetName = "WithPassword")] - [securestring] - $Password, - - [Parameter(ParameterSetName = "WithoutPassword")] - [Alias('NoPassword')] - [switch] - $WithoutPassword, - - [Parameter()] - [securestring] - $SsoCustomerIdentifier, - - [Parameter()] - [array] - $Permissions, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] - [cultureinfo] - $Culture - ) - - if (-Not $Culture) { - try { $Culture = Get-Culture } - catch { $Culture = 'en' } - } - - $body = @{ - email = $Email - name = $Name - language = $Culture | Resolve-TeamViewerLanguage - permissions = $Permissions -join ',' - } - - if ($Password -And -Not $WithoutPassword) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - - if ($SsoCustomerIdentifier) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) - $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - - $resourceUri = "$(Get-TeamViewerApiUri)/users" - if ($PSCmdlet.ShouldProcess("$Name <$Email>", "Create user")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response | ConvertTo-TeamViewerUser) - $result.Email = $Email - Write-Output $result - } -} - - - -function New-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" - $body = @{ name = $Name } - } - - Process { - if ($PSCmdlet.ShouldProcess($Name, "Create user group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - } -} - - - - -function New-TeamViewerUserRole { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true )] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('UserRoleName')] - [string] - $Name, - - [Parameter(Mandatory = $false)] - [AllowEmptyCollection()] - [object[]] - $Permissions - ) - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles" - $body = @{ - Name = $Name - Permissions = @() - } - - if ($Permissions) { - $body.Permissions = @($Permissions) - } - } - - Process { - if ($PSCmdlet.ShouldProcess($Name, 'Create User Role')) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response.Role | ConvertTo-TeamViewerUserRole) - Write-Output $result - } - } - -} - - - -function Publish-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [object[]] - $User, - - [Parameter()] - [ValidateSet("read", "readwrite")] - $Permissions = "read" - ) - - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Permissions - - $groupId = $Group | Resolve-TeamViewerGroupId - $userIds = $User | Resolve-TeamViewerUserId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/share_group" - $body = @{ - users = @($userIds | ForEach-Object { @{ - userid = $_ - permissions = $Permissions - } }) - } - - if ($PSCmdlet.ShouldProcess($userids, "Add group share")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Remove-TeamViewerAssignment { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - - if (Test-TeamViewerInstallation) { - $OS = Get-OperatingSystem - $CurrentDirectory = Get-Location - $installationDirectory = Get-TeamViewerInstallationDirectory - Set-Location $installationDirectory - if ($OS -eq 'Windows') { - $cmd = 'unassign' - $FilePath = 'TeamViewer.exe' - } - elseif ($OS -eq 'Linux') { - $cmd = 'teamviewer unassign' - $FilePath = 'sudo' - } - $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-AssignmentErrorCode - Set-Location $CurrentDirectory - } - else { - Write-Output 'TeamViewer is not installed.' - } -} - - - - - -function Remove-TeamViewerContact { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] - [Alias("ContactId")] - [Alias("Id")] - [object] - $Contact - ) - Process { - $contactId = $Contact | Resolve-TeamViewerContactId - $resourceUri = "$(Get-TeamViewerApiUri)/contacts/$contactId" - if ($PSCmdlet.ShouldProcess($contactId, "Remove contact")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerCustomization { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if (Get-OperatingSystem -eq 'Windows') { - if (Test-TeamViewerInstallation) { - $installationDirectory = Get-TeamViewerInstallationDirectory - $currentDirectory = Get-Location - Set-Location $installationDirectory - $cmd = 'customize --remove' - $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-CustomizationErrorCode - Set-Location $currentDirectory - } - else { - Write-Error 'TeamViewer is not installed' - } - } - else { - Write-Error 'Customization is currently supported only on Windows.' - } -} - - - -function Remove-TeamViewerDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] - [Alias("DeviceId")] - [Alias("Id")] - [object] - $Device - ) - Process { - $deviceId = $Device | Resolve-TeamViewerDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" - if ($PSCmdlet.ShouldProcess($deviceId, "Remove device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group - ) - Process { - $groupId = $Group | Resolve-TeamViewerGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Remove group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $groupId = $Group | Resolve-TeamViewerManagedGroupId - - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($deviceId, "Remove device from managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManagedDeviceManagement { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias('DeviceId')] - [object] - $Device - ) - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($deviceId, 'Remove Management from a device (clears all managers and groups)')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group - ) - Process { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Remove managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManager { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "ByDeviceId")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { - if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { - $PSCmdlet.ThrowTerminatingError( - ("Invalid manager object. Manager must be a group or device manager." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $_ | Resolve-TeamViewerManagerId - })] - [Alias("ManagerId")] - [Alias("Id")] - [object] - $Manager, - - [Parameter(ParameterSetName = 'ByDeviceId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(ParameterSetName = 'ByGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias("GroupId")] - [object] - $Group - ) - Process { - $deviceId = $null - $groupId = $null - if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { - if ($Device -Or $Group) { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if ($Manager.DeviceId) { - $deviceId = $Manager.DeviceId - } - elseif ($Manager.GroupId) { - $groupId = $Manager.GroupId - } - } - elseif ($Device) { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - } - elseif ($Group) { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - } - else { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $managerId = $Manager | Resolve-TeamViewerManagerId - if ($deviceId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" - $processMessage = "Remove manager from managed device" - } - elseif ($groupId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" - $processMessage = "Remove manager from managed group" - } - - if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerPolicy { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias('PolicyId')] - [object] - $Policy - ) - Process { - $policyId = $Policy | Resolve-TeamViewerPolicyId - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" - - if ($PSCmdlet.ShouldProcess($policyId, "Delete policy")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamviewerPolicyFromManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true)] - [PolicyType] - $PolicyType - ) - Begin { - $body = @{ - 'policy_type' = [int]$PolicyType - } - } - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/policy/remove" - - if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerPSProxy { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - $global:TeamViewerProxyUriRemoved = $true - $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ - $global:TeamViewerProxyUriSet = $null - $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - [Environment]::SetEnvironmentVariable('TeamViewerProxyUri','', 'User') - } -} - - - -function Remove-TeamViewerRoleFromAccount { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [object] - $UserRoleId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [Alias('Id', 'UserIds')] - [string[]] - $Accounts - ) - - Begin { - $id = $UserRoleId | Resolve-TeamViewerUserRoleId - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" - $AccountsToRemove = @() - $body = @{ - UserIds = @() - UserRoleId = $id - } - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - - } - - Process { - if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from Role')) { - if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { - $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } - } - foreach ($Account in $Accounts) { - $AccountsToRemove += $Account - $body.UserIds = @($AccountsToRemove) - } - } - if ($AccountsToRemove.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $AccountsToRemove = @() - } - } - End { - if ($AccountsToRemove.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - -function Remove-TeamViewerRoleFromUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup - ) - - Begin { - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/usergroup" - $body = @{ - UserGroupId = $UserGroup - } - } - - - Process { - if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign Role from User Group')) { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - } -} - - - -function Remove-TeamViewerSsoExclusion { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] - [Alias("Domain")] - [object] - $DomainId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [string[]] - $Email - ) - Begin { - $id = $DomainId | Resolve-TeamViewerSsoDomainId - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" - $emailsToRemove = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-RequestInternal { - $body = @{ - emails = @($emailsToRemove) - } - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } - Process { - if ($PSCmdlet.ShouldProcess($Email, "Remove SSO exclusion")) { - $emailsToRemove += $Email - } - if ($emailsToRemove.Length -eq 100) { - Invoke-RequestInternal - $emailsToRemove = @() - } - } - End { - if ($emailsToRemove.Length -gt 0) { - Invoke-RequestInternal - } - } -} - - - -function Remove-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [Alias("Id")] - [object] - $User, - - [Parameter()] - [switch] - $Permanent - ) - Process { - $userId = $User | Resolve-TeamViewerUserId - $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" - - if ($Permanent) { - $resourceUri += '?isPermanentDelete=true' - } - - if ($PSCmdlet.ShouldProcess($userId, "Remove user")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" - } - - Process { - if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Remove user group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup, - - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] - [Alias('UserGroupMemberId')] - [Alias('MemberId')] - [Alias('UserId')] - [Alias('User')] - [object[]] - $UserGroupMember - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToRemove = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $UserGroupMember - function Invoke-TeamViewerRestMethodInternal { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - - function Get-MemberId { - switch ($UserGroupMember) { - { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { - $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId - return $UserGroupMember - } - Default { - if ($UserGroupMember -notmatch 'u[0-9]+') { - ForEach-Object { - $UserGroupMember = [int[]]$UserGroupMember - } - } - else { - ForEach-Object { - $UserGroupMember = [int[]]$UserGroupMember.trim('u') - } - } - return $UserGroupMember - } - } - } - } - - Process { - # when members are provided as pipeline input, each member is provided as separate statement, - # thus the members should be combined to one array in order to send a single request - if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { - if (Get-MemberId -isnot [array]) { - $membersToRemove += @(Get-MemberId) - } - else { - $membersToRemove += Get-MemberId - } - $payload = $membersToRemove -join ', ' - $body = "[$payload]" - } - - # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` - # in order to accept more members - if ($membersToRemove.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $membersToRemove = @() - } - } - - End { - # A request needs to be send if there were less than 100 members - if ($membersToRemove.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - -function Remove-TeamViewerUserRole { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [Alias('Id')] - [object] - $UserRoleId - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$UserRoleId" - } - - Process { - if ($PSCmdlet.ShouldProcess($UserRoleId.ToString(), 'Remove User Role')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Restart-TeamViewerService { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if ($PSCmdlet.ShouldProcess('TeamViewer service')) { - switch (Get-OperatingSystem) { - 'Windows' { - Restart-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon restart - } - } - } -} - - - -function Set-TeamViewerAccount { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('DisplayName')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $Password, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $OldPassword, - - [Parameter(ParameterSetName = 'ByParameters')] - [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] - [object] - $EmailLanguage, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($Name) { - $body['name'] = $Name - } - if ($Email) { - $body['email'] = $Email - } - if ($Password) { - if (-Not $OldPassword) { - $PSCmdlet.ThrowTerminatingError( - ("Old password required when attempting to change account password." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($OldPassword) - $body['oldpassword'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($EmailLanguage) { - $body['email_language'] = $EmailLanguage | Resolve-TeamViewerLanguage - } - } - 'ByProperties' { - @('name', 'email', 'password', 'oldpassword', 'email_language') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the account." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $resourceUri = "$(Get-TeamViewerApiUri)/account" - - if ($PSCmdlet.ShouldProcess("TeamViewer account")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Set-TeamViewerAPIUri { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [string]$NewUri, - [Parameter(Mandatory = $false)] - [bool]$Default - ) - - $config = [TeamViewerConfiguration]::GetInstance() - $PSDefaultParameterValues = @{'CmdletName:Default' = $true } - - if ($PSCmdlet.ShouldProcess('TeamViewer account')) { - if ($NewUri) { - $config.APIUri = $NewUri - Write-Output "TeamViewer API URL set to: $($config.APIUri)" - } - elseif ($Default) { - $config.APIUri = 'https://webapi.teamviewer.com/api/v1' - Write-Output "TeamViewer API URL set to: $($config.APIUri)" - } - } - -} - - - -function Set-TeamViewerDevice { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Default")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] - [Alias("DeviceId")] - [Alias("Id")] - [object] - $Device, - - [Parameter(ParameterSetName = "ChangeGroup")] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(ParameterSetName = "ChangePolicy")] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId -AllowInherit -AllowNone } )] - [Alias("PolicyId")] - [object] - $Policy, - - [Parameter()] - [Alias("Alias")] - [string] - $Name, - - [Parameter()] - [string] - $Description, - - [Parameter()] - [securestring] - $Password - ) - Begin { - $body = @{} - - if ($Name) { - $body['alias'] = $Name - } - if ($Description) { - $body['description'] = $Description - } - if ($Password) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($Group) { - $body['groupid'] = $Group | Resolve-TeamViewerGroupId - } - if ($Policy) { - $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId -AllowNone -AllowInherit - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the device." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $deviceId = $Device | Resolve-TeamViewerDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Set-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group, - - [Parameter(ParameterSetName = 'ByParameters')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias("PolicyId")] - [object] - $Policy, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - Begin { - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - $body['name'] = $Name - if ($Policy) { - $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId - } - } - 'ByProperties' { - @('name', 'policy_id') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the group." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $groupId = $Group | Resolve-TeamViewerGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Update group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Set-TeamViewerManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Alias("Alias")] - [string] - $Name, - - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias("PolicyId")] - [object] - $Policy, - - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("ManagedGroupId")] - [object] - $ManagedGroup - ) - Begin { - $body = @{} - - if ($Name) { - $body['name'] = $Name - } - if ($Policy) { - $body['teamviewerPolicyId'] = $Policy | Resolve-TeamViewerPolicyId - } - elseif ($ManagedGroup) { - $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId - } - - if ($Policy -And $ManagedGroup) { - $PSCmdlet.ThrowTerminatingError( - ("The combination of parameters -Policy and -ManagedGroup is not allowed." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the managed device." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Set-TeamViewerManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByParameters')] - [string] - $Name, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - Begin { - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - $body['name'] = $Name - } - 'ByProperties' { - @('name') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the managed group." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Update managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Set-TeamViewerManager { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { - if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { - $PSCmdlet.ThrowTerminatingError( - ("Invalid manager object. Manager must be a group or device manager." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $_ | Resolve-TeamViewerManagerId - })] - [Alias("ManagerId")] - [Alias("Id")] - [object] - $Manager, - - [Parameter(ParameterSetName = 'Device_ByParameters')] - [Parameter(ParameterSetName = 'Device_ByProperties')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(ParameterSetName = 'Group_ByParameters')] - [Parameter(ParameterSetName = 'Group_ByProperties')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(ParameterSetName = 'Device_ByParameters')] - [Parameter(ParameterSetName = 'Group_ByParameters')] - [AllowEmptyCollection()] - [string[]] - $Permissions, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByProperties')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByProperties')] - [hashtable] - $Property - ) - Begin { - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch -Wildcard ($PSCmdlet.ParameterSetName) { - '*ByParameters' { - $body['permissions'] = @($Permissions) - } - '*ByProperties' { - @('permissions') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the manager." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $deviceId = $null - $groupId = $null - if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { - if ($Device -Or $Group) { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if ($Manager.DeviceId) { - $deviceId = $Manager.DeviceId - } - elseif ($Manager.GroupId) { - $groupId = $Manager.GroupId - } - } - elseif ($Device) { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - } - elseif ($Group) { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - } - else { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $managerId = $Manager | Resolve-TeamViewerManagerId - if ($deviceId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" - $processMessage = "Update managed device manager" - } - elseif ($groupId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" - $processMessage = "Update managed group manager" - } - - if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Set-TeamViewerPolicy { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias('PolicyId')] - [object] - $Policy, - - [Parameter(ParameterSetName = 'ByParameters')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [object[]] - $Settings, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($Name) { - $body['name'] = $Name - } - if ($Settings) { - $body['settings'] = $Settings - } - } - 'ByProperties' { - @('name', 'settings') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the policy." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $policyId = $Policy | Resolve-TeamViewerPolicyId - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" - - if ($PSCmdlet.ShouldProcess($policyId, "Update policy")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json -Depth 25))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -$global:TeamViewerProxyUriSet = $null - -function Set-TeamViewerPSProxy { - [CmdletBinding(SupportsShouldProcess =$true)] - param ( - [Parameter(Mandatory=$true)] - [Uri] - $ProxyUri - ) - - if($PSCmdlet.ShouldProcess($ProxyUri,"Sets proxy for WebAPI")){ - $global:TeamViewerProxyUriSet = $ProxyUri - $global:TeamViewerProxyUriRemoved = $false - $global:TeamViewerProxyUriRemoved | Out-Null - - [Environment]::SetEnvironmentVariable("TeamViewerProxyUri", $ProxyUri, "User") - - Write-Output "Proxy set to $TeamViewerProxyUriSet" - } -} - - - - -function Set-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [Alias("Id")] - [object] - $User, - - [Parameter(ParameterSetName = 'ByParameters')] - [boolean] - $Active, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('DisplayName')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $Password, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $SsoCustomerIdentifier, - - [Parameter(ParameterSetName = 'ByParameters')] - [array] - $Permissions, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($PSBoundParameters.ContainsKey('Active')) { - $body['active'] = $Active - } - if ($Email) { - $body['email'] = $Email - } - if ($Name) { - $body['name'] = $Name - } - if ($Password) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($SsoCustomerIdentifier) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) - $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($Permissions) { - $body['permissions'] = $Permissions -join ',' - } - } - 'ByProperties' { - @('active', 'email', 'name', 'password', 'sso_customer_id', 'permissions') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the user." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $userId = Resolve-TeamViewerUserId -User $User - $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" - - if ($PSCmdlet.ShouldProcess($userId, "Update user profile")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Set-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup, - - [Parameter(Mandatory = $true)] - [Alias("UserGroupName")] - [string] - $Name - ) - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" - $body = @{ name = $Name } - } - Process { - if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Change user group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - } -} - - - - -function Set-TeamViewerUserRole { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true )] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('UserRoleName')] - [string] - $Name, - - [Parameter(Mandatory = $false)] - [AllowEmptyCollection()] - [object[]] - $Permissions, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [object] - $UserRoleId - ) - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles" - $body = @{ - Name = $Name - Permissions = @() - UserRoleId = $UserRoleId - - } - if ($Permissions) { - $body.Permissions = @($Permissions) - } - } - Process { - if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = $response - Write-Output $result - } - } - -} - - - -function Start-TeamViewerService { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if ($PSCmdlet.ShouldProcess("TeamViewer service")) { - switch (Get-OperatingSystem) { - 'Windows' { - Start-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon start - } - } - } -} - - - -function Stop-TeamViewerService { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if ($PSCmdlet.ShouldProcess("TeamViewer service")) { - switch (Get-OperatingSystem) { - 'Windows' { - Stop-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon stop - } - } - } -} - - - -function Test-TeamViewerConnectivity { - param( - [Parameter()] - [switch] - $Quiet - ) - - $endpoints = @( - @{ Hostname = 'webapi.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'login.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'meeting.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'sso.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'download.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'configdl.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'get.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'go.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'client.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'feedbackservice.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'remotescriptingstorage.blob.core.windows.net'; TcpPort = 443; } - @{ Hostname = 'chatlivestorage.blob.core.windows.net'; TcpPort = 443; } - ) - 1..16 | ForEach-Object { - $endpoints += @{ Hostname = "router$_.teamviewer.com"; TcpPort = (5938, 443, 80) } - } - - $results = $endpoints | ForEach-Object { - $endpoint = $_ - $portSucceeded = $endpoint.TcpPort | Where-Object { - Write-Verbose "Checking endpoint $($endpoint.Hostname) on port $_" - Test-TcpConnection -Hostname $endpoint.Hostname -Port $_ - } | Select-Object -First 1 - $endpoint.Succeeded = [bool]$portSucceeded - $endpoint.TcpPort = if ($endpoint.Succeeded) { $portSucceeded } else { $endpoint.TcpPort } - return $endpoint - } - - if ($Quiet) { - ![bool]($results | Where-Object { -Not $_.Succeeded }) - } - else { - $results | ` - ForEach-Object { New-Object PSObject -Property $_ } | ` - Select-Object -Property Hostname, TcpPort, Succeeded | ` - Sort-Object Hostname - } -} - - - -function Test-TeamViewerInstallation { - if (Get-TeamViewerInstallationDirectory) { - return $true - } - else { - return $false - } -} - - - -function Unpublish-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(Mandatory = $true)] - [Alias("UserId")] - [object[]] - $User - ) - - $groupId = $Group | Resolve-TeamViewerGroupId - $userIds = $User | Resolve-TeamViewerUserId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/unshare_group" - $body = @{users = @($userIds) } - - if ($PSCmdlet.ShouldProcess($userids, "Remove group share")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - +$ModuleTypes = @( Get-ChildItem -Path "$PSScriptRoot/TeamViewerPS.Types.ps1" -ErrorAction SilentlyContinue ) +$PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -ErrorAction SilentlyContinue ) +$PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -ErrorAction SilentlyContinue ) +@($ModuleTypes + $PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } +Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md new file mode 100644 index 0000000..ccec592 --- /dev/null +++ b/Docs/TeamViewerPS.md @@ -0,0 +1,260 @@ +# TeamViewerPS + +# SHORT DESCRIPTION + +TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally +installed TeamViewer client. + +# LONG DESCRIPTION + +TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally +installed TeamViewer client. + +The module provides functions for the following categories: + +## Device Assignment + +Assign or unassign a device to a company + +The following functions are available in this category: + +[`Add-TeamViewerAssinment.md`](Help/Add-TeamViewerAssignment.md) + +[`Remove-TeamViewerAssignment.md`](Help/Remove-TeamViewerAssignment.md) + +## Customize Client + +Manage customization of the locally installed TeamViewer Client. + +[`Add-TeamViewerCustomization`](Help/Add-TeamViewerCustomization.md) + +[`Remove-TeamViewerCustomization`](Help/Remove-TeamViewerCustomization.md) + +## Computers & Contacts list + +Remotely manage the Computers & Contacts list via the TeamViewer Web API. + +The following functions are available in this category: + +[`Get-TeamViewerContact`](Help/Get-TeamViewerContact.md) + +[`Get-TeamViewerDevice`](Help/Get-TeamViewerDevice.md) + +[`Get-TeamViewerGroup`](Help/Get-TeamViewerGroup.md) + +[`New-TeamViewerContact`](Help/New-TeamViewerContact.md) + +[`New-TeamViewerDevice`](Help/New-TeamViewerDevice.md) + +[`New-TeamViewerGroup`](Help/New-TeamViewerGroup.md) + +[`Remove-TeamViewerContact`](Help/Remove-TeamViewerContact.md) + +[`Remove-TeamViewerDevice`](Help/Remove-TeamViewerDevice.md) + +[`Remove-TeamViewerGroup`](Help/Remove-TeamViewerGroup.md) + +[`Set-TeamViewerDevice`](Help/Set-TeamViewerDevice.md) + +[`Set-TeamViewerGroup`](Help/Set-TeamViewerGroup.md) + +[`Publish-TeamViewerGroup`](Help/Publish-TeamViewerGroup.md) + +[`Unpublish-TeamViewerGroup`](Help/Unpublish-TeamViewerGroup.md) + +## User management + +Remotely manage the user accounts of a TeamViewer company via the TeamViewer +Web API. + +The following functions are available in this category: + +[`Get-TeamViewerUser`](Help/Get-TeamViewerUser.md) + +[`New-TeamViewerUser`](Help/New-TeamViewerUser.md) + +[`Remove-TeamViewerUser`](Help/Remove-TeamViewerUser.md) + +[`Set-TeamViewerUser`](Help/Set-TeamViewerUser.md) + +## User groups + +Remotely manage the user groups of a TeamViewer company via the +TeamViewer Web API. Have user groups to organize company members. + +The following functions are available in this category: + +[`Get-TeamViewerUserGroup`](Help/Get-TeamViewerUserGroup.md) + +[`New-TeamViewerUserGroup`](Help/New-TeamViewerUserGroup.md) + +[`Set-TeamViewerUserGroup`](Help/Set-TeamViewerUserGroup.md) + +[`Remove-TeamViewerUserGroup`](Help/Remove-TeamViewerUserGroup.md) + +[`Get-TeamViewerUserGroupMember`](Help/Get-TeamViewerUserGroupMember.md) + +[`Add-TeamViewerUserGroupMember`](Help/Add-TeamViewerUserGroupMember.md) + +[`Remove-TeamViewerUserGroupMember`](Help/Remove-TeamViewerUserGroupMember.md) + +## Role Management + +Remotely manage the user roles of a TeamViewer company via the +TeamViewer Web API. Have user roles to assign roles to company members. + +The following functions are available in this category: + +[`Get-TeamViewerUserRole`](Help/Get-TeamViewerUserRole.md) + +[`New-TeamViewerUserRole`](Help/New-TeamViewerUserRole.md) + +[`Set-TeamViewerUserRole`](Help/Set-TeamViewerUserRole.md) + +[`Remove-TeamViewerUserRole`](Help/Remove-TeamViewerUserRole.md) + +[`Get-TeamViewerRoleAssignmentToAccount`](Help/Get-TeamviewerRoleAssignmentToAccount.md) + +[`Get-TeamViewerRoleAssignmentToUserGroup`](Help/Get-TeamViewerRoleAssignmentToUserGroup.md) + +[`Add-TeamViewerRoleToAccount`](Help/Add-TeamViewerRoleToAccount) + +[`Add-TeamViewerRoleToUserGroup`](Help/Add-TeamViewerRoleToAccount) + +[`Remove-TeamViewerRoleFromAccount`](Help/Remove-TeamviewerRoleFromAccount) + +[`Remove-TeamViewerRoleFromUserroup`](Help/Remove-TeamViewerRoleFromUserGroup) + +## Managed groups + +Remotely manage the managed groups and managed devices of an account via the +TeamViewer Web API. + +The following functions are available in this category: + +[`Get-TeamViewerManagedDevice`](Help/Get-TeamViewerManagedDevice.md) + +[`Get-TeamViewerManagedGroup`](Help/Get-TeamViewerManagedGroup.md) + +[`Get-TeamViewerManagementId`](Help/Get-TeamViewerManagementId.md) + +[`Get-TeamViewerManager`](Help/Get-TeamViewerManager.md) + +[`New-TeamViewerManagedGroup`](Help/New-TeamViewerManagedGroup.md) + +[`Set-TeamViewerManagedDevice`](Help/Set-TeamViewerManagedDevice.md) + +[`Set-TeamViewerManagedGroup`](Help/Set-TeamViewerManagedGroup.md) + +[`Set-TeamViewerManager`](Help/Set-TeamViewerManager.md) + +[`Add-TeamViewerManagedDevice`](Help/Add-TeamViewerManagedDevice.md) + +[`Add-TeamViewerManager`](Help/Add-TeamViewerManager.md) + +[`Remove-TeamViewerManagedDevice`](Help/Remove-TeamViewerManagedDevice.md) + +[`Remove-TeamViewerManagedDeviceManagement`](Help/Remove-TeamViewerManagedDeviceManagement.md) + +[`Remove-TeamViewerManagedGroup`](Help/Remove-TeamViewerManagedGroup.md) + +[`Remove-TeamViewerManager`](Help/Remove-TeamViewerManager.md) + +[`Remove-TeamViewerPolicyFromManagedDevice`](Cmdlets/Pulic/Remove-TeamViewerpolicyFromManagedDevice.md) + +## Policy management + +Remotely manage the policies of a TeamViewer company via the TeamViewer Web API. + +The following functions are available in this category: + +[`Get-TeamViewerPolicy`](Help/Get-TeamViewerPolicy.md) + +[`New-TeamViewerPolicy`](Help/New-TeamViewerPolicy.md) + +[`Remove-TeamViewerPolicy`](Help/Remove-TeamViewerPolicy.md) + +[`Set-TeamViewerPolicy`](Help/Set-TeamViewerPolicy.md) + +## Single Sign-On management + +Remotely manage Single Sign-On configurations via the TeamViewer Web API. + +The following functions are available in this category: + +[`Get-TeamViewerSsoDomain`](Help/Get-TeamViewerSsoDomain.md) + +[`Get-TeamViewerSsoExclusion`](Help/Get-TeamViewerSsoExclusion.md) + +[`Add-TeamViewerSsoExclusion`](Help/Add-TeamViewerSsoExclusion.md) + +[`Remove-TeamViewerSsoExclusion`](Help/Remove-TeamViewerSsoExclusion.md) + +## Event logs & reporting + +Retrieve event log entries or connection-reports of a TeamViewer company via the TeamViewer Web +API. + +[`Get-TeamViewerConnectionReport`](Help/Get-TeamViewerConnectionReport.md) + +[`Get-TeamViewerEventLog`](Help/Get-TeamViewerEventLog.md) + +## Local TeamViewer utilities + +Utilities that help managing the local TeamViewer installation. + +The following functions are available in this category: + +[`Export-TeamViewerSystemInformation`](Help/Export-TeamViewerSystemInformation.md) + +[`Get-TeamViewerId`](Help/Get-TeamViewerId.md) + +[`Get-TeamViewerService`](Help/Get-TeamViewerService.md) + +[`Get-TeamViewerVersion`](Help/Get-TeamViewerVersion.md) + +[`Get-TeamViewerInstallationDirectory`](Help/Get-TeamViewerInstallationDirectory.md) + +[`Get-TeamViewerLogFilePath`](Help/Get-TeamViewerLogFilePath.md) + +[`Invoke-TeamViewerPackageDownload`](Help/Invoke-TeamViewerPackageDownload.md) + +[`Restart-TeamViewerService`](Help/Restart-TeamViewerService.md) + +[`Start-TeamViewerService`](Help/Start-TeamViewerService.md) + +[`Stop-TeamViewerService`](Help/Stop-TeamViewerService.md) + +[`Test-TeamViewerConnectivity`](Help/Test-TeamViewerConnectivity.md) + +[`Test-TeamViewerInstallation`](Help/Test-TeamViewerInstallation.md) + +## Web API utilities + +Utilities that help working with the TeamViewer Web API related functions. + +The following functions are available in this category: + +[`Connect-TeamViewerApi`](Help/Connect-TeamViewerApi.md) + +[`Disconnect-TeamViewerApi`](Help/Disconnect-TeamViewerApi.md) + +[`Invoke-TeamViewerPing`](Help/Invoke-TeamViewerPing.md) + +## Web API proxy + +Functions that manage proxy when working with TeamViewer Web API reated functions. + +The following functions are available in this category: + +[`Set-TeamViewerPSProxy`](Help/Set-TeamViewerPSProxy.md) + +[`Remove-TeamViewerPSProxy`](Help/Remove-TeamViewerPSProxy.md) + +# SEE ALSO + +TeamViewerPS project page on Github: + +TeamViewer Web API Documentation: + +TeamViewer Homepage: diff --git a/Docs/about_TeamViewerPS.md b/Docs/about_TeamViewerPS.md deleted file mode 100644 index 4b066e5..0000000 --- a/Docs/about_TeamViewerPS.md +++ /dev/null @@ -1,199 +0,0 @@ -# TeamViewerPS - -## about_TeamViewerPS - -# SHORT DESCRIPTION - -TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally -installed TeamViewer client. - -# LONG DESCRIPTION - -TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally -installed TeamViewer client. - -The module provides functions for the following categories: - -## Computers & Contacts list - -Remotely manage the Computers & Contacts list via the TeamViewer Web API. - -The following functions are available in this category: - -[`Get-TeamViewerContact`](Cmdlets/Public/Get-TeamViewerContact.md) - -[`Get-TeamViewerDevice`](Cmdlets/Public/Get-TeamViewerDevice.md) - -[`Get-TeamViewerGroup`](Cmdlets/Public/Get-TeamViewerGroup.md) - -[`New-TeamViewerContact`](Cmdlets/Public/New-TeamViewerContact.md) - -[`New-TeamViewerDevice`](Cmdlets/Public/New-TeamViewerDevice.md) - -[`New-TeamViewerGroup`](Cmdlets/Public/New-TeamViewerGroup.md) - -[`Remove-TeamViewerContact`](Cmdlets/Public/Remove-TeamViewerContact.md) - -[`Remove-TeamViewerDevice`](Cmdlets/Public/Remove-TeamViewerDevice.md) - -[`Remove-TeamViewerGroup`](Cmdlets/Public/Remove-TeamViewerGroup.md) - -[`Set-TeamViewerDevice`](Cmdlets/Public/Set-TeamViewerDevice.md) - -[`Set-TeamViewerGroup`](Cmdlets/Public/Set-TeamViewerGroup.md) - -[`Publish-TeamViewerGroup`](Cmdlets/Public/Publish-TeamViewerGroup.md) - -[`Unpublish-TeamViewerGroup`](Cmdlets/Public/Unpublish-TeamViewerGroup.md) - -## User management - -Remotely manage the user accounts of a TeamViewer company via the TeamViewer -Web API. - -The following functions are available in this category: - -[`Get-TeamViewerUser`](Cmdlets/Public/Get-TeamViewerUser.md) - -[`New-TeamViewerUser`](Cmdlets/Public/New-TeamViewerUser.md) - -[`Remove-TeamViewerUser`](Cmdlets/Public/Remove-TeamViewerUser.md) - -[`Set-TeamViewerUser`](Cmdlets/Public/Set-TeamViewerUser.md) - -## User groups - -Remotely manage the user groups of a TeamViewer company via the -TeamViewer Web API. Have user groups to organize company members. - -The following functions are available in this category: - -[`Get-TeamViewerUserGroup`](Cmdlets/Public/Get-TeamViewerUserGroup.md) - -[`New-TeamViewerUserGroup`](Cmdlets/Public/New-TeamViewerUserGroup.md) - -[`Set-TeamViewerUserGroup`](Cmdlets/Public/Set-TeamViewerUserGroup.md) - -[`Remove-TeamViewerUserGroup`](Cmdlets/Public/Remove-TeamViewerUserGroup.md) - -[`Get-TeamViewerUserGroupMember`](Cmdlets/Public/Get-TeamViewerUserGroupMember.md) - -[`Add-TeamViewerUserGroupMember`](Cmdlets/Public/Add-TeamViewerUserGroupMember.md) - -[`Remove-TeamViewerUserGroupMember`](Cmdlets/Public/Remove-TeamViewerUserGroupMember.md) - -## Managed groups - -Remotely manage the managed groups and managed devices of an account via the -TeamViewer Web API. - -The following functions are available in this category: - -[`Get-TeamViewerManagedDevice`](Cmdlets/Public/Get-TeamViewerManagedDevice.md) - -[`Get-TeamViewerManagedGroup`](Cmdlets/Public/Get-TeamViewerManagedGroup.md) - -[`Get-TeamViewerManagementId`](Cmdlets/Public/Get-TeamViewerManagementId.md) - -[`Get-TeamViewerManager`](Cmdlets/Public/Get-TeamViewerManager.md) - -[`New-TeamViewerManagedGroup`](Cmdlets/Public/New-TeamViewerManagedGroup.md) - -[`Set-TeamViewerManagedDevice`](Cmdlets/Public/Set-TeamViewerManagedDevice.md) - -[`Set-TeamViewerManagedGroup`](Cmdlets/Public/Set-TeamViewerManagedGroup.md) - -[`Set-TeamViewerManager`](Cmdlets/Public/Set-TeamViewerManager.md) - -[`Add-TeamViewerManagedDevice`](Cmdlets/Public/Add-TeamViewerManagedDevice.md) - -[`Add-TeamViewerManager`](Cmdlets/Public/Add-TeamViewerManager.md) - -[`Remove-TeamViewerManagedDevice`](Cmdlets/Public/Remove-TeamViewerManagedDevice.md) - -[`Remove-TeamViewerManagedDeviceManagement`](Cmdlets/Public/Remove-TeamViewerManagedDeviceManagement.md) - -[`Remove-TeamViewerManagedGroup`](Cmdlets/Public/Remove-TeamViewerManagedGroup.md) - -[`Remove-TeamViewerManager`](Cmdlets/Public/Remove-TeamViewerManager.md) - -## Policy management - -Remotely manage the policies of a TeamViewer company via the TeamViewer Web API. - -The following functions are available in this category: - -[`Get-TeamViewerPolicy`](Cmdlets/Public/Get-TeamViewerPolicy.md) - -[`New-TeamViewerPolicy`](Cmdlets/Public/New-TeamViewerPolicy.md) - -[`Remove-TeamViewerPolicy`](Cmdlets/Public/Remove-TeamViewerPolicy.md) - -[`Set-TeamViewerPolicy`](Cmdlets/Public/Set-TeamViewerPolicy.md) - -## Single Sign-On management - -Remotely manage Single Sign-On configurations via the TeamViewer Web API. - -The following functions are available in this category: - -[`Get-TeamViewerSsoDomain`](Cmdlets/Public/Get-TeamViewerSsoDomain.md) - -[`Get-TeamViewerSsoExclusion`](Cmdlets/Public/Get-TeamViewerSsoExclusion.md) - -[`Add-TeamViewerSsoExclusion`](Cmdlets/Public/Add-TeamViewerSsoExclusion.md) - -[`Remove-TeamViewerSsoExclusion`](Cmdlets/Public/Remove-TeamViewerSsoExclusion.md) - -## Event logs & reporting - -Retrieve event log entries or connection-reports of a TeamViewer company via the TeamViewer Web -API. - -[`Get-TeamViewerConnectionReport`](Cmdlets/Public/Get-TeamViewerConnectionReport.md) - -[`Get-TeamViewerEventLog`](Cmdlets/Public/Get-TeamViewerEventLog.md) - -## Local TeamViewer utilities - -Utilities that help managing the local TeamViewer installation. - -The following functions are available in this category: - -[`Get-TeamViewerId`](Cmdlets/Public/Get-TeamViewerId.md) - -[`Get-TeamViewerService`](Cmdlets/Public/Get-TeamViewerService.md) - -[`Get-TeamViewerVersion`](Cmdlets/Public/Get-TeamViewerVersion.md) - -[`Invoke-TeamViewerPackageDownload`](Cmdlets/Public/Invoke-TeamViewerPackageDownload.md) - -[`Restart-TeamViewerService`](Cmdlets/Public/Restart-TeamViewerService.md) - -[`Start-TeamViewerService`](Cmdlets/Public/Start-TeamViewerService.md) - -[`Stop-TeamViewerService`](Cmdlets/Public/Stop-TeamViewerService.md) - -[`Test-TeamViewerConnectivity`](Cmdlets/Public/Test-TeamViewerConnectivity.md) - -[`Test-TeamViewerInstallation`](Cmdlets/Public/Test-TeamViewerInstallation.md) - -## Web API utilities - -Utilities that help working with the TeamViewer Web API related functions. - -The following functions are available in this category: - -[`Connect-TeamViewerApi`](Cmdlets/Public/Connect-TeamViewerApi.md) - -[`Disconnect-TeamViewerApi`](Cmdlets/Public/Disconnect-TeamViewerApi.md) - -[`Invoke-TeamViewerPing`](Cmdlets/Public/Invoke-TeamViewerPing.md) - -# SEE ALSO - -TeamViewerPS project page on Github: - -TeamViewer Web API Documentation: - -TeamViewer Homepage: diff --git a/README.md b/README.md index 2332750..88c6453 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ The documentation and help can be accessed using the following commands: ```powershell # Starting point of the documentation -Get-Help about_TeamViewerPS +Get-Help TeamViewerPS # List of available commands of this module Get-Command -Module TeamViewerPS @@ -72,7 +72,7 @@ The module provides functions for the following categories: - _Single Sign-On management_ - _Local TeamViewer utilities_ -Please see the [about_TeamViewerPS](docs/about_TeamViewerPS.md) article for a more detailed list. +Please see the [TeamViewerPS](docs/TeamViewerPS.md) article for a more detailed list. ## Prerequisites From 4eff85c111d60a5a6457264afd8446ff2c44bb1c Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 12 Oct 2023 19:07:34 +0200 Subject: [PATCH 065/110] Remove old company permissions from user --- .vscode/spelling | 3 +- CHANGELOG.md | 68 +++++++++++--------- Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 | 9 ++- Cmdlets/Public/Get-TeamViewerUser.ps1 | 44 ++++++------- Cmdlets/Public/New-TeamViewerUser.ps1 | 39 +++++------ Cmdlets/Public/Set-TeamViewerUser.ps1 | 31 +++------ Docs/Help/Get-TeamViewerUser.md | 29 ++------- Docs/Help/New-TeamViewerUser.md | 30 ++------- Docs/Help/Set-TeamViewerUser.md | 36 ++--------- Tests/Public/Get-TeamViewerUser.Tests.ps1 | 21 ++---- Tests/Public/Set-TeamViewerUser.Tests.ps1 | 42 +++--------- 11 files changed, 120 insertions(+), 232 deletions(-) diff --git a/.vscode/spelling b/.vscode/spelling index e4a4095..8acd0fb 100644 --- a/.vscode/spelling +++ b/.vscode/spelling @@ -1,6 +1,7 @@ -// TeamViewerPS +// Project TeamViewer TeamViewer's +TeamViewerPS // Powershell cmdlet diff --git a/CHANGELOG.md b/CHANGELOG.md index f592afa..7e15274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,71 +4,76 @@ ### Added -- Added 'Set-TeamViewerApiURi' to use TeamViewer test API. -- Added user role commands to remotely manage user roles of a TeamViewer company. -- Added `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. -- Added `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. -- Added `Export-TeamViewerSystemInformation` to create zip file for support. -- Added `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. -- Added `Get-TeamViewerInstallationDirectory` to return installation directory. -- Added `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. +- Adds user role commands to manage user roles of a TeamViewer company. +- Adds `Set-TeamViewerApiURi` to use TeamViewer test API. +- Adds `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. +- Adds `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. +- Adds `Export-TeamViewerSystemInformation` to create zip file for support. +- Adds `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. +- Adds `Get-TeamViewerInstallationDirectory` to return installation directory. +- Adds `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. ### Changed -- Extended `Invoke-TeamViewerPackageDownload` with MSI package type. -- Folder structure modified. -- `-RemovePolicy` switch removed from `Set-TeamViewerManagedDevice`. +- Extends `Invoke-TeamViewerPackageDownload` with MSI package type. +- Modifies general folder structure. +- Removes `-RemovePolicy` switch from `Set-TeamViewerManagedDevice`. ### Fixed -- Fixed `Get-TeamViewerLinuxGlobalConfig` to handle null values. +- Fixes `Get-TeamViewerLinuxGlobalConfig` to handle null values. ## 1.5.2 (2023-09-18) -- Remove-TeamViewerPolicyFromManagedDevice has been added. -- ManagedGroupId parameter has been added to Set-TeamViewerManagedDevice. +### Added + +- Adds `Remove-TeamViewerPolicyFromManagedDevice` to remove a policy from a managed device. + +### Changed + +- Adds `ManagedGroupId` parameter to `Set-TeamViewerManagedDevice`. ## 1.5.1 (2023-07-18) -- Improved `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember` +- Improves `User ID` parameter handling for `Add-TeamViewerUserGroupMember` and `Remove-TeamViewerUserGroupMember`. ## 1.5.0 (2023-05-24) ### Added -- Added `Remove-TeamViewerUser` cmdlet to remove user from TeamViewer company. (Thanks @OtterKring) -- Added `Remove-TeamViewerManagedDeviceManagement` to unmanage a device. +- Adds `Remove-TeamViewerUser` cmdlet to remove user from TeamViewer company. (Thanks @OtterKring) +- Adds `Remove-TeamViewerManagedDeviceManagement` to un-manage a device. ### Changed -- Extended `Add-TeamViewerManager` to add user group as manager. (Thanks @OtterKring) -- Extended `TeamViewerManagedDevice` to have "LastSeenAt" available for managed devices +- Extends `Add-TeamViewerManager` to add user group as manager. (Thanks @OtterKring) +- Adds `LastSeenAt` to `TeamViewerManagedDevice` for managed devices. ## 1.4.0 (2022-04-19) -### Fixed +### Added -- Fixed `-Group` parameter of `Remove-TeamViewerManagedDevice` to be mandatory. +- Adds `Get-TeamViewerConnectionReport` cmdlet to fetch TeamViewer session / connection reports. -### Added +### Fixed -- Added `Get-TeamViewerConnectionReport` cmdlet to fetch TeamViewer session/connection reports. +- Fixes `-Group` parameter of `Remove-TeamViewerManagedDevice` to be mandatory. ## 1.3.1 (2021-11) -### Fixed +### Changed -- Fixed `Set-TeamViewerPolicy` to support changing policy settings. +- `Get-TeamViewerUser` includes license information. -### Changed +### Fixed -- Result of `Get-TeamViewerUser` now also includes license information. +- Fixes `Set-TeamViewerPolicy` to support changing policy settings. ## 1.3.0 (2021-11-29) ### Added -- Adds command `Get-TeamViewerEventLog` to fetch event log entries. +- Adds `Get-TeamViewerEventLog` to fetch event log entries. - Adds user group commands to remotely manage user groups of a TeamViewer company. ## 1.2.0 (2021-07-19) @@ -77,8 +82,7 @@ - Adds command `Set-TeamViewerManagedDevice` to change properties of a managed device. - Adds optional `Policy` property to `Get-TeamViewerManagedDevice` result entries. -- Adds `-Device` parameter to `Get-TeamViewerManagedGroup` command, allowing to - fetch all managed groups that a particular device is part of. +- Adds `-Device` parameter to `Get-TeamViewerManagedGroup` command, allowing to fetch all managed groups that a particular device is part of. ## 1.1.0 (2021-04-15) @@ -89,8 +93,8 @@ ### Changed -- Improved bulk support for `Add-TeamViewerSsoExclusion` and `Remove-TeamViewerSsoExclusion`. +- Improves bulk support for `Add-TeamViewerSsoExclusion` and `Remove-TeamViewerSsoExclusion`. ## 1.0.0 (2021-01-15) -- Initial release of TeamViewerPS \ No newline at end of file +- Initial release of TeamViewerPS diff --git a/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 index 2443c95..988ff4a 100644 --- a/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 +++ b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 @@ -8,18 +8,20 @@ function ConvertTo-TeamViewerUser { [ValidateSet('All', 'Minimal')] $PropertiesToLoad = 'All' ) + process { $properties = @{ Id = $InputObject.id Name = $InputObject.name Email = $InputObject.email } + if ($PropertiesToLoad -Eq 'All') { $properties += @{ - Permissions = $InputObject.permissions -split ',' Active = $InputObject.active LastAccessDate = $InputObject.last_access_date | ConvertTo-DateTime } + if ($InputObject.activated_license_id) { $properties += @{ ActivatedLicenseId = [guid]$InputObject.activated_license_id @@ -27,17 +29,20 @@ function ConvertTo-TeamViewerUser { ActivatedSubLicenseName = $InputObject.activated_subLicense_name } } + if ($InputObject.activated_meeting_license_key) { $properties += @{ ActivatedMeetingLicenseId = [guid]$InputObject.activated_meeting_license_key } } } + $result = New-Object -TypeName PSObject -Property $properties $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.User') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { Write-Output "$($this.Name) <$($this.Email)>" } + Write-Output $result } } diff --git a/Cmdlets/Public/Get-TeamViewerUser.ps1 b/Cmdlets/Public/Get-TeamViewerUser.ps1 index 72ce67d..c5d34cd 100644 --- a/Cmdlets/Public/Get-TeamViewerUser.ps1 +++ b/Cmdlets/Public/Get-TeamViewerUser.ps1 @@ -1,69 +1,61 @@ function Get-TeamViewerUser { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] + [CmdletBinding(DefaultParameterSetName = 'FilteredList')] param( [Parameter(Mandatory = $true)] [securestring] $ApiToken, - [Parameter(ParameterSetName = "ByUserId")] + [Parameter(ParameterSetName = 'ByUserId')] [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] + [Alias('UserId')] [string] $Id, - [Parameter(ParameterSetName = "FilteredList")] - [Alias("PartialName")] + [Parameter(ParameterSetName = 'FilteredList')] + [Alias('PartialName')] [string] $Name, - [Parameter(ParameterSetName = "FilteredList")] + [Parameter(ParameterSetName = 'FilteredList')] [string[]] $Email, - [Parameter(ParameterSetName = "FilteredList")] - [string[]] - $Permissions, - [Parameter()] - [ValidateSet("All", "Minimal")] - $PropertiesToLoad = "All" + [ValidateSet('All', 'Minimal')] + $PropertiesToLoad = 'All' ) $parameters = @{ } switch ($PropertiesToLoad) { - "All" { $parameters.full_list = $true } - "Minimal" { } + 'All' { + $parameters.full_list = $true + } + 'Minimal' { + } } $resourceUri = "$(Get-TeamViewerApiUri)/users" switch ($PsCmdlet.ParameterSetName) { - "ByUserId" { + 'ByUserId' { $resourceUri += "/$Id" $parameters = $null } - "FilteredList" { + 'FilteredList' { if ($Name) { $parameters['name'] = $Name } + if ($Email) { $parameters['email'] = ($Email -join ',') } - if ($Permissions) { - $parameters['permissions'] = ($Permissions -join ',') - } } } $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop + -ApiToken $ApiToken -Uri $resourceUri -Method Get -Body $parameters -WriteErrorTo $PSCmdlet -ErrorAction Stop - if ($PsCmdlet.ParameterSetName -Eq "ByUserId") { + if ($PsCmdlet.ParameterSetName -Eq 'ByUserId') { Write-Output ($response | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) } else { diff --git a/Cmdlets/Public/New-TeamViewerUser.ps1 b/Cmdlets/Public/New-TeamViewerUser.ps1 index 258daff..2381fe0 100644 --- a/Cmdlets/Public/New-TeamViewerUser.ps1 +++ b/Cmdlets/Public/New-TeamViewerUser.ps1 @@ -1,5 +1,5 @@ function New-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "WithPassword")] + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'WithPassword')] param( [Parameter(Mandatory = $true)] [securestring] @@ -15,11 +15,11 @@ function New-TeamViewerUser { [string] $Name, - [Parameter(Mandatory = $true, ParameterSetName = "WithPassword")] + [Parameter(Mandatory = $true, ParameterSetName = 'WithPassword')] [securestring] $Password, - [Parameter(ParameterSetName = "WithoutPassword")] + [Parameter(ParameterSetName = 'WithoutPassword')] [Alias('NoPassword')] [switch] $WithoutPassword, @@ -28,10 +28,6 @@ function New-TeamViewerUser { [securestring] $SsoCustomerIdentifier, - [Parameter()] - [array] - $Permissions, - [Parameter()] [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] [cultureinfo] @@ -39,15 +35,18 @@ function New-TeamViewerUser { ) if (-Not $Culture) { - try { $Culture = Get-Culture } - catch { $Culture = 'en' } + try { + $Culture = Get-Culture + } + catch { + $Culture = 'en' + } } $body = @{ - email = $Email - name = $Name - language = $Culture | Resolve-TeamViewerLanguage - permissions = $Permissions -join ',' + email = $Email + name = $Name + language = $Culture | Resolve-TeamViewerLanguage } if ($Password -And -Not $WithoutPassword) { @@ -63,18 +62,12 @@ function New-TeamViewerUser { } $resourceUri = "$(Get-TeamViewerApiUri)/users" - if ($PSCmdlet.ShouldProcess("$Name <$Email>", "Create user")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - + if ($PSCmdlet.ShouldProcess("$Name <$Email>", 'Create user')) { + $response = Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Post -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) -WriteErrorTo $PSCmdlet -ErrorAction Stop $result = ($response | ConvertTo-TeamViewerUser) $result.Email = $Email + Write-Output $result } } diff --git a/Cmdlets/Public/Set-TeamViewerUser.ps1 b/Cmdlets/Public/Set-TeamViewerUser.ps1 index e95dd47..835b905 100644 --- a/Cmdlets/Public/Set-TeamViewerUser.ps1 +++ b/Cmdlets/Public/Set-TeamViewerUser.ps1 @@ -7,8 +7,8 @@ function Set-TeamViewerUser { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [Alias("Id")] + [Alias('UserId')] + [Alias('Id')] [object] $User, @@ -34,10 +34,6 @@ function Set-TeamViewerUser { [securestring] $SsoCustomerIdentifier, - [Parameter(ParameterSetName = 'ByParameters')] - [array] - $Permissions, - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] [hashtable] $Property @@ -65,34 +61,23 @@ function Set-TeamViewerUser { $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null } - if ($Permissions) { - $body['permissions'] = $Permissions -join ',' - } } 'ByProperties' { - @('active', 'email', 'name', 'password', 'sso_customer_id', 'permissions') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } + @('active', 'email', 'name', 'password', 'sso_customer_id') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } } } if ($body.Count -eq 0) { $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the user." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + ('The given input does not change the user.' | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } $userId = Resolve-TeamViewerUserId -User $User $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" - if ($PSCmdlet.ShouldProcess($userId, "Update user profile")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null + if ($PSCmdlet.ShouldProcess($userId, 'Update user profile')) { + Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Put -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) -WriteErrorTo $PSCmdlet | Out-Null } } diff --git a/Docs/Help/Get-TeamViewerUser.md b/Docs/Help/Get-TeamViewerUser.md index 085e128..ee439cf 100644 --- a/Docs/Help/Get-TeamViewerUser.md +++ b/Docs/Help/Get-TeamViewerUser.md @@ -16,8 +16,7 @@ Retrieve users of a TeamViewer company. ### FilteredList (Default) ```powershell -Get-TeamViewerUser -ApiToken [-Name ] [-Email ] [-Permissions ] - [-PropertiesToLoad ] [] +Get-TeamViewerUser -ApiToken [-Name ] [-Email ] [-PropertiesToLoad ] [] ``` ### ByUserId @@ -78,8 +77,7 @@ Accept wildcard characters: False ### -Email -Optional list of email addresses. Can be used to only return users that exactly -match one of the given email addresses. +Optional list of email addresses. Can be used to only return users that exactly match one of the given email addresses. ```yaml Type: String[] @@ -111,8 +109,7 @@ Accept wildcard characters: False ### -Name -Optional name filter parameter that can be used to only list users that have -the given string in their name. +Optional name filter parameter that can be used to only list users that have the given string in their name. ```yaml Type: String @@ -126,27 +123,9 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Permissions - -Optional permissions filter that can be used to only list users that have -certain permissions. Multiple values can be given. - -```yaml -Type: String[] -Parameter Sets: FilteredList -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -PropertiesToLoad -Can be used to retrieve all available properties of a user or just a -stripped-down minimal set of user properties. +Can be used to retrieve all available properties of a user or just a stripped-down minimal set of user properties. ```yaml Type: Object diff --git a/Docs/Help/New-TeamViewerUser.md b/Docs/Help/New-TeamViewerUser.md index 7d512da..0125200 100644 --- a/Docs/Help/New-TeamViewerUser.md +++ b/Docs/Help/New-TeamViewerUser.md @@ -17,16 +17,14 @@ Create a new TeamViewer company user. ```powershell New-TeamViewerUser -ApiToken -Email -Name -Password - [-SsoCustomerIdentifier ] [-Permissions ] [-Culture ] [-WhatIf] [-Confirm] - [] + [-SsoCustomerIdentifier ] [-Culture ] [-WhatIf] [-Confirm] [] ``` ### WithoutPassword ```powershell New-TeamViewerUser -ApiToken -Email -Name [-WithoutPassword] - [-SsoCustomerIdentifier ] [-Permissions ] [-Culture ] [-WhatIf] [-Confirm] - [] + [-SsoCustomerIdentifier ] [-Culture ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -41,8 +39,7 @@ Creates a new user for the company that is associated to the API access token. PS /> New-TeamViewerUser -Email 'test@example.test' -Name 'Test User' ``` -Create a new user with the given email address and name. The password will be -prompted. +Create a new user with the given email address and name. The password will be prompted. ### Example 2 @@ -50,9 +47,8 @@ prompted. PS /> New-TeamViewerUser -Email 'test@example.test' -Name 'Test User' -WithoutPassword ``` -Create a new user with the given email address and name. It will be created -without a password. The user must reset the password through the TeamViewer -web page. +Create a new user with the given email address and name. +It will be created without a password. The user must reset the password through the TeamViewer web page. ## PARAMETERS @@ -152,22 +148,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Permissions - -Optional list of permissions to give to the new user. - -```yaml -Type: Array -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -SsoCustomerIdentifier Optional TeamViewer SSO customer identifier. If given, the user will be created diff --git a/Docs/Help/Set-TeamViewerUser.md b/Docs/Help/Set-TeamViewerUser.md index 6fd6ae6..4d359ba 100644 --- a/Docs/Help/Set-TeamViewerUser.md +++ b/Docs/Help/Set-TeamViewerUser.md @@ -17,15 +17,13 @@ Change properties of a TeamViewer company user. ```powershell Set-TeamViewerUser -ApiToken -User [-Active ] [-Email ] - [-Name ] [-Password ] [-SsoCustomerIdentifier ] [-Permissions ] - [-WhatIf] [-Confirm] [] + [-Name ] [-Password ] [-SsoCustomerIdentifier ] [-WhatIf] [-Confirm] [] ``` ### ByProperties ```powershell -Set-TeamViewerUser -ApiToken -User -Property [-WhatIf] [-Confirm] - [] +Set-TeamViewerUser -ApiToken -User -Property [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -66,8 +64,7 @@ PS /> $ssoCustomerIdentifier = ("abc" | ConvertTo-SecureString -AsPlainText -For PS /> Set-TeamViewerUser -UserId 'u1234' -SsoCustomerIdentifier $ssoCustomerIdentifier ``` -Do the SSO activation step for the given user. This can also be used to repair a possibly broken -SSO login token for that user. +Do the SSO activation step for the given user. This can also be used to repair a possibly broken SSO login token for that user. ## PARAMETERS @@ -167,28 +164,11 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Permissions - -Updated set of permissions of the company user. -Please see the TeamViewer API documentation for a list of valid values. - -```yaml -Type: Array -Parameter Sets: ByParameters -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Property Change policy information using a hashtable object. Valid hashtable keys are: -`active`, `email`, `name`, `password`, `sso_customer_id`, `permissions` +`active`, `email`, `name`, `password`, `sso_customer_id` ```yaml Type: Hashtable @@ -204,9 +184,8 @@ Accept wildcard characters: False ### -SsoCustomerIdentifier -Optional TeamViewer SSO customer identifier. If given, the user will be updated -with SSO activation step already done. With this option, the user must not -enter the TeamViewer password at when doing Single Sign-On. +Optional TeamViewer SSO customer identifier. If given, the user will be updated with SSO activation step already done. +With this option, the user must not enter the TeamViewer password at when doing Single Sign-On. ```yaml Type: SecureString @@ -223,8 +202,7 @@ Accept wildcard characters: False ### -User Object that can be used to identify the user. -This can either be the user ID or a user object that has been received using -other module functions. +This can either be the user ID or a user object that has been received using other module functions. ```yaml Type: Object diff --git a/Tests/Public/Get-TeamViewerUser.Tests.ps1 b/Tests/Public/Get-TeamViewerUser.Tests.ps1 index b25503e..0ceb008 100644 --- a/Tests/Public/Get-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUser.Tests.ps1 @@ -1,8 +1,7 @@ BeforeAll { . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` - ForEach-Object { . $_.FullName } + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken @@ -23,18 +22,14 @@ Describe 'Get-TeamViewerUser' { Get-TeamViewerUser -ApiToken $testApiToken Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $ApiToken -eq $testApiToken -And ` - $Uri -eq '//unit.test/users' -And ` - $Method -eq 'Get' } + $ApiToken -eq $testApiToken -And $Uri -eq '//unit.test/users' -And $Method -eq 'Get' } } It 'Should call the correct API endpoint for single user' { Get-TeamViewerUser -ApiToken $testApiToken -User 'u1234' Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $ApiToken -eq $testApiToken -And ` - $Uri -eq '//unit.test/users/u1234' -And ` - $Method -eq 'Get' } + $ApiToken -eq $testApiToken -And $Uri -eq '//unit.test/users/u1234' -And $Method -eq 'Get' } } It 'Should return User objects' { @@ -45,30 +40,28 @@ Describe 'Get-TeamViewerUser' { It 'Should allow to filter by name' { Get-TeamViewerUser -ApiToken $testApiToken -Name 'TestName' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $Body -And $Body['name'] -eq 'TestName' } } It 'Should allow to filter by emails' { Get-TeamViewerUser -ApiToken $testApiToken -Email 'user1@unit.test', 'user2@unit.test' - Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $Body -And $Body['email'] -eq 'user1@unit.test,user2@unit.test' } - } - It 'Should allow to filter by permissions' { - Get-TeamViewerUser -ApiToken $testApiToken -Permissions 'p1', 'p2', 'p3' Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $Body -And $Body['permissions'] -eq 'p1,p2,p3' } + $Body -And $Body['email'] -eq 'user1@unit.test,user2@unit.test' } } It 'Should allow to retrieve all properties' { Get-TeamViewerUser -ApiToken $testApiToken -PropertiesToLoad 'All' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $Body -And $Body['full_list'] -eq $true } } It 'Should allow to retrieve a minimal set of properties' { Get-TeamViewerUser -ApiToken $testApiToken -PropertiesToLoad 'Minimal' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $Body -And $Body['full_list'] -eq $null } } diff --git a/Tests/Public/Set-TeamViewerUser.Tests.ps1 b/Tests/Public/Set-TeamViewerUser.Tests.ps1 index b9dedfe..b652c34 100644 --- a/Tests/Public/Set-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUser.Tests.ps1 @@ -1,8 +1,7 @@ BeforeAll { . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerUser.ps1" - @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` - ForEach-Object { . $_.FullName } + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } $testApiToken = [securestring]@{} $null = $testApiToken @@ -15,36 +14,26 @@ BeforeAll { # We do this only for testing [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param() - Process { $_ | ConvertTo-SecureString -AsPlainText -Force } + Process { + $_ | ConvertTo-SecureString -AsPlainText -Force + } } } Describe 'Set-TeamViewerUser' { It 'Should call the correct API endpoint' { - Set-TeamViewerUser ` - -ApiToken $testApiToken ` - -User 'u1234' ` - -Name 'Updated User Name' + Set-TeamViewerUser -ApiToken $testApiToken -User 'u1234' -Name 'Updated User Name' Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $ApiToken -eq $testApiToken -And ` - $Uri -eq '//unit.test/users/u1234' -And ` - $Method -eq 'Put' } + $ApiToken -eq $testApiToken -And $Uri -eq '//unit.test/users/u1234' -And $Method -eq 'Put' } } It 'Should change user properties' { $testPassword = 'Test1234' | ConvertTo-TestPassword $testSsoCustomerId = 'SsoTest' | ConvertTo-TestPassword - Set-TeamViewerUser ` - -ApiToken $testApiToken ` - -User 'u1234' ` - -Name 'Updated User Name' ` - -Email 'foo@bar.com' ` - -Password $testPassword ` - -SsoCustomerIdentifier $testSsoCustomerId ` - -Permissions 'ManageAdmins', 'ManageUsers' ` - -Active $false + + Set-TeamViewerUser -ApiToken $testApiToken -User 'u1234' -Name 'Updated User Name' -Email 'foo@bar.com' -Password $testPassword -SsoCustomerIdentifier $testSsoCustomerId -Active $false $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -52,20 +41,15 @@ Describe 'Set-TeamViewerUser' { $body.email | Should -Be 'foo@bar.com' $body.password | Should -Be 'Test1234' $body.sso_customer_id | Should -Be 'SsoTest' - $body.permissions | Should -Be 'ManageAdmins,ManageUsers' $body.active | Should -BeFalse } It 'Should accept user properties as hashtable' { - Set-TeamViewerUser ` - -ApiToken $testApiToken ` - -User 'u1234' ` - -Property @{ + Set-TeamViewerUser -ApiToken $testApiToken -User 'u1234' -Property @{ name = 'Updated User Name' email = 'foo@bar.com' password = 'Test1234' sso_customer_id = 'SsoTest' - permissions = 'ManageAdmins,ManageUsers' active = $false } @@ -75,16 +59,10 @@ Describe 'Set-TeamViewerUser' { $body.email | Should -Be 'foo@bar.com' $body.password | Should -Be 'Test1234' $body.sso_customer_id | Should -Be 'SsoTest' - $body.permissions | Should -Be 'ManageAdmins,ManageUsers' $body.active | Should -BeFalse } It 'Should throw if hashtable does not contain any valid change' { - { Set-TeamViewerUser ` - -ApiToken $testApiToken ` - -User 'u1234' ` - -Property @{ - foo = 'bar' - } } | Should -Throw + { Set-TeamViewerUser -ApiToken $testApiToken -User 'u1234' -Property @{ foo = 'bar' } } | Should -Throw } } From 37767091e4374587dff9a91428cd6d9183f6cdb2 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 12 Oct 2023 19:32:54 +0200 Subject: [PATCH 066/110] Updates Readme.md --- README.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 88c6453..3b4cdb6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally ## Installation & Update -Install TeamViewerPS from the Powershell Gallery using the following command: +Downloads and installs TeamViewerPS from the Powershell Gallery using the following command: ```powershell Install-Module TeamViewerPS @@ -23,9 +23,6 @@ Update-Module TeamViewerPS The following example code shows how to interact with the TeamViewer Web API functions by retrieving the list of users of a TeamViewer company: ```powershell -# Downloads and installs the module from Powershell Gallery -Install-Module TeamViewerPS - # Stores API token for Powershell session # 1. Create a TeamViewer API access token in the Management Console: https://login.teamviewer.com # 2. Enter the API token in the shown dialog @@ -38,8 +35,6 @@ Get-TeamViewerUser Another example below shows how to display the TeamViewer ID as well as the version of the locally installed TeamViewer client: ```powershell -Install-Module TeamViewerPS - # Returns the TeamViewer Id of the locally installed TeamViewer client Get-TeamViewerId @@ -67,12 +62,13 @@ The module provides functions for the following categories: - _Computers & Contacts list_ - _User management_ - _User groups_ +- _User roles_ - _Managed groups_ - _Policy management_ -- _Single Sign-On management_ +- _Single Sign-On (SSO) management_ - _Local TeamViewer utilities_ -Please see the [TeamViewerPS](docs/TeamViewerPS.md) article for a more detailed list. +Please see the [TeamViewerPS](Docs/TeamViewerPS.md) article for a more detailed list. ## Prerequisites @@ -88,6 +84,7 @@ Please see the file `LICENSE.md`. ## Links -- [TeamViewerPS project page on Github](https://github.com/TeamViewer/TeamViewerPS) -- [TeamViewer Web API documentation](https://webapi.teamviewer.com/api/v1/docs/index) -- [TeamViewer website](https://www.teamviewer.com/) +- [TeamViewer company website](https://www.teamviewer.com/) +- [TeamViewerPS project on Github](https://github.com/TeamViewer/TeamViewerPS) +- [TeamViewer web API documentation](https://webapi.teamviewer.com/api/v1/docs/index) +- [TeamViewerPS on Powershell Gallery](https://www.powershellgallery.com/packages/TeamViewerPS) From 4877941c72cb9523e1e383c82ba788aa275ff4bc Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Thu, 12 Oct 2023 19:48:31 +0200 Subject: [PATCH 067/110] Updates New-TeamViewerUser.Tests.ps1 --- Tests/Public/New-TeamViewerUser.Tests.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/Public/New-TeamViewerUser.Tests.ps1 b/Tests/Public/New-TeamViewerUser.Tests.ps1 index 38888a6..9cf28c7 100644 --- a/Tests/Public/New-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/New-TeamViewerUser.Tests.ps1 @@ -15,7 +15,9 @@ BeforeAll { # We do this only for testing [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param() - Process { $_ | ConvertTo-SecureString -AsPlainText -Force } + Process { + $_ | ConvertTo-SecureString -AsPlainText -Force + } } } @@ -25,9 +27,7 @@ Describe 'New-TeamViewerUser' { New-TeamViewerUser -ApiToken $testApiToken -Name 'Unit Test User' -Email 'user1@unit.test' -WithoutPassword Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { - $ApiToken -eq $testApiToken -And ` - $Uri -eq '//unit.test/users' -And ` - $Method -eq 'Post' } + $ApiToken -eq $testApiToken -And $Uri -eq '//unit.test/users' -And $Method -eq 'Post' } } It 'Should include the given name and email in the request' { @@ -64,6 +64,7 @@ Describe 'New-TeamViewerUser' { It 'Should allow to specify a password for the new user' { $testPassword = 'Test1234' | ConvertTo-TestPassword + New-TeamViewerUser -ApiToken $testApiToken -Name 'Unit Test User' -Email 'user1@unit.test' -Password $testPassword $mockArgs.Body | Should -Not -BeNullOrEmpty @@ -73,6 +74,7 @@ Describe 'New-TeamViewerUser' { It 'Should allow to create a SSO-enabled user' { $testSsoCustomerId = 'my-sso-customer-id' | ConvertTo-TestPassword + New-TeamViewerUser -ApiToken $testApiToken -Name 'Unit Test User' -Email 'user1@unit.test' -WithoutPassword -SsoCustomerIdentifier $testSsoCustomerId $mockArgs.Body | Should -Not -BeNullOrEmpty From 41a1bd557be3efad0f11978bdd2197f3754dbc5a Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Sat, 14 Oct 2023 18:14:48 +0200 Subject: [PATCH 068/110] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e15274..5b7a0ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,9 @@ ### Changed - Extends `Invoke-TeamViewerPackageDownload` with MSI package type. -- Modifies general folder structure. - Removes `-RemovePolicy` switch from `Set-TeamViewerManagedDevice`. +- Removes `-Permissions` switch from `Get-TeamViewerUser`, `New-TeamViewerUser` and `Remove-TeamViewerUser`. +- Modifies general module folder structure. ### Fixed From b231eaf8f5d8a6e2738a4f3e63c1d384cd16e692 Mon Sep 17 00:00:00 2001 From: Karthick Gandhi Date: Mon, 16 Oct 2023 09:23:30 +0200 Subject: [PATCH 069/110] PSShouldProcess warning fix --- Cmdlets/Public/Remove-TeamViewerAssignment.ps1 | 8 +++++--- Cmdlets/Public/Remove-TeamViewerCustomization.ps1 | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 b/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 index ac2a59c..277f445 100644 --- a/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerAssignment.ps1 @@ -16,9 +16,11 @@ function Remove-TeamViewerAssignment { $cmd = 'teamviewer unassign' $FilePath = 'sudo' } - $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-AssignmentErrorCode - Set-Location $CurrentDirectory + if ($PSCmdlet.ShouldProcess($installationDirectory, 'Remove device assignment')) { + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } } else { Write-Output 'TeamViewer is not installed.' diff --git a/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 b/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 index 0bc1fdc..13c90b7 100644 --- a/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerCustomization.ps1 @@ -8,8 +8,10 @@ function Remove-TeamViewerCustomization { $currentDirectory = Get-Location Set-Location $installationDirectory $cmd = 'customize --remove' - $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-CustomizationErrorCode + if ($PSCmdlet.ShouldProcess($installationDirectory, 'Remove Client Customization')) { + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + } Set-Location $currentDirectory } else { From f22755852a25b7a5e898a3f34b3bb6a81f34e740 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Tue, 17 Oct 2023 23:10:20 +0200 Subject: [PATCH 070/110] Renames Add-TeamViewerRoleToAccount --- ...leToAccount.ps1 => Add-TeamViewerAccountToRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ...RoleToAccount.md => Add-TeamViewerAccountToRole.md} | 10 +++++----- Docs/TeamViewerPS.md | 8 ++++---- ...Tests.ps1 => Add-TeamViewerAccountToRole.Tests.ps1} | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) rename Cmdlets/Public/{Add-TeamViewerRoleToAccount.ps1 => Add-TeamViewerAccountToRole.ps1} (98%) rename Docs/Help/{Add-TeamViewerRoleToAccount.md => Add-TeamViewerAccountToRole.md} (90%) rename Tests/Public/{Add-TeamViewerRoleToAccount.Tests.ps1 => Add-TeamViewerAccountToRole.Tests.ps1} (87%) diff --git a/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 b/Cmdlets/Public/Add-TeamViewerAccountToRole.ps1 similarity index 98% rename from Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 rename to Cmdlets/Public/Add-TeamViewerAccountToRole.ps1 index cec810b..ac9e56d 100644 --- a/Cmdlets/Public/Add-TeamViewerRoleToAccount.ps1 +++ b/Cmdlets/Public/Add-TeamViewerAccountToRole.ps1 @@ -1,4 +1,4 @@ -function Add-TeamViewerRoleToAccount { +function Add-TeamViewerAccountToRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 3e6c9d8..110fae0 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerRoleToAccount', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Add-TeamViewerRoleToAccount.md b/Docs/Help/Add-TeamViewerAccountToRole.md similarity index 90% rename from Docs/Help/Add-TeamViewerRoleToAccount.md rename to Docs/Help/Add-TeamViewerAccountToRole.md index 518164a..a7a70fb 100644 --- a/Docs/Help/Add-TeamViewerRoleToAccount.md +++ b/Docs/Help/Add-TeamViewerAccountToRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerRoleToAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerAccountToRole.md schema: 2.0.0 --- -# Add-TeamViewerRoleToAccount +# Add-TeamViewerAccountToRole ## SYNOPSIS @@ -14,7 +14,7 @@ Assign user role to a list of accountIds. ## SYNTAX ```powershell -Add-TeamViewerRoleToAccount [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] +Add-TeamViewerAccountToRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Assigns user role to one or many users. User role should belong to the TeamViewe ### Example 1 ```powershell -PS /> Add-TeamViewerRoleToAccount -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Add-TeamViewerAccountToRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. @@ -35,7 +35,7 @@ Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `12 ### Example 2 ```powershell -PS /> @('123', '456', '789') | Add-TeamViewerRoleToAccount -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Add-TeamViewerAccountToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index ccec592..ae16f5b 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -14,7 +14,7 @@ The module provides functions for the following categories: ## Device Assignment -Assign or unassign a device to a company +Assign or unassign a device to a company The following functions are available in this category: @@ -100,7 +100,7 @@ The following functions are available in this category: ## Role Management -Remotely manage the user roles of a TeamViewer company via the +Remotely manage the user roles of a TeamViewer company via the TeamViewer Web API. Have user roles to assign roles to company members. The following functions are available in this category: @@ -117,9 +117,9 @@ The following functions are available in this category: [`Get-TeamViewerRoleAssignmentToUserGroup`](Help/Get-TeamViewerRoleAssignmentToUserGroup.md) -[`Add-TeamViewerRoleToAccount`](Help/Add-TeamViewerRoleToAccount) +[`Add-TeamViewerAccountToRole`](Help/Add-TeamViewerAccountToRole) -[`Add-TeamViewerRoleToUserGroup`](Help/Add-TeamViewerRoleToAccount) +[`Add-TeamViewerRoleToUserGroup`](Help/Add-TeamViewerAccountToRole) [`Remove-TeamViewerRoleFromAccount`](Help/Remove-TeamviewerRoleFromAccount) diff --git a/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 b/Tests/Public/Add-TeamViewerAccountToRole.Tests.ps1 similarity index 87% rename from Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 rename to Tests/Public/Add-TeamViewerAccountToRole.Tests.ps1 index 9d42545..93b634a 100644 --- a/Tests/Public/Add-TeamViewerRoleToAccount.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerAccountToRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerRoleToAccount.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerAccountToRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -19,10 +19,10 @@ BeforeAll { } } } -Describe 'Add-TeamViewerRoleToAccount' { +Describe 'Add-TeamViewerAccountToRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerRoleToAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Add-TeamViewerAccountToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -33,7 +33,7 @@ Describe 'Add-TeamViewerRoleToAccount' { It 'Should assign the given account to the user role' { - Add-TeamViewerRoleToAccount ` + Add-TeamViewerAccountToRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId ` -Accounts $testAccount @@ -47,7 +47,7 @@ Describe 'Add-TeamViewerRoleToAccount' { } It 'Should accept pipeline input' { - $testAccount | Add-TeamViewerRoleToAccount ` + $testAccount | Add-TeamViewerAccountToRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty From 03bd35368b7c4150caaf8681529f7120e19fee23 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Tue, 17 Oct 2023 23:13:20 +0200 Subject: [PATCH 071/110] Renames Add-TeamViewerRoleToUserGroup --- ...eToUserGroup.ps1 => Add-TeamViewerUserGroupToRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ...oleToUserGroup.md => Add-TeamViewerUserGroupToRole.md} | 8 ++++---- Docs/TeamViewerPS.md | 2 +- ....Tests.ps1 => Add-TeamViewerUserGroupToRole.Tests.ps1} | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) rename Cmdlets/Public/{Add-TeamViewerRoleToUserGroup.ps1 => Add-TeamViewerUserGroupToRole.ps1} (97%) rename Docs/Help/{Add-TeamViewerRoleToUserGroup.md => Add-TeamViewerUserGroupToRole.md} (91%) rename Tests/Public/{Add-TeamViewerRoleToUserGroup.Tests.ps1 => Add-TeamViewerUserGroupToRole.Tests.ps1} (85%) diff --git a/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 similarity index 97% rename from Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 rename to Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 index e560a5a..93aacea 100644 --- a/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 @@ -1,4 +1,4 @@ -function Add-TeamViewerRoleToUserGroup { +function Add-TeamViewerUserGroupToRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 110fae0..4bc02cd 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Add-TeamViewerRoleToUserGroup.md b/Docs/Help/Add-TeamViewerUserGroupToRole.md similarity index 91% rename from Docs/Help/Add-TeamViewerRoleToUserGroup.md rename to Docs/Help/Add-TeamViewerUserGroupToRole.md index 4f7e88c..dd4ce4a 100644 --- a/Docs/Help/Add-TeamViewerRoleToUserGroup.md +++ b/Docs/Help/Add-TeamViewerUserGroupToRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerRoleToUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserGroupToRole.md schema: 2.0.0 --- -# Add-TeamViewerRoleToUserGroup +# Add-TeamViewerUserGroupToRole ## SYNOPSIS @@ -14,7 +14,7 @@ Assign user role to a user group. ## SYNTAX ```powershell -Add-TeamViewerRoleToUserGroup [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] +Add-TeamViewerUserGroupToRole [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Assigns user role to a user group of the TeamViewer company associated with the ### Example 1 ```powershell -PS /> Add-TeamViewerRoleToUserGroup -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 +PS /> Add-TeamViewerUserGroupToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 ``` The given user group `1001` gets assigned to the user role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index ae16f5b..fa9c285 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -119,7 +119,7 @@ The following functions are available in this category: [`Add-TeamViewerAccountToRole`](Help/Add-TeamViewerAccountToRole) -[`Add-TeamViewerRoleToUserGroup`](Help/Add-TeamViewerAccountToRole) +[`Add-TeamViewerUserGroupToRole`](Help/Add-TeamViewerAccountToRole) [`Remove-TeamViewerRoleFromAccount`](Help/Remove-TeamviewerRoleFromAccount) diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 similarity index 85% rename from Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 rename to Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 index 4ebe068..ba0e965 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerRoleToUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserGroupToRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -18,9 +18,9 @@ BeforeAll { } } } -Describe 'Add-TeamViewerRoleToUserGroup' { +Describe 'Add-TeamViewerUserGroupToRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Add-TeamViewerUserGroupToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` From a7334d35d5405197edba898cb345a04b32f2065e Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Tue, 17 Oct 2023 23:31:35 +0200 Subject: [PATCH 072/110] Renames Remove-TeamViewerRoleFromAccount --- ...1 => Remove-TeamViewerAccountFromRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ...md => Remove-TeamViewerAccountFromRole.md} | 22 +++++++++---------- Docs/TeamViewerPS.md | 2 +- ...emove-TeamViewerAccountFromRole.Tests.ps1} | 10 ++++----- 5 files changed, 19 insertions(+), 19 deletions(-) rename Cmdlets/Public/{Remove-TeamViewerRoleFromAccount.ps1 => Remove-TeamViewerAccountFromRole.ps1} (97%) rename Docs/Help/{Remove-TeamViewerRoleFromAccount.md => Remove-TeamViewerAccountFromRole.md} (77%) rename Tests/Public/{Remove-TeamViewerRoleFromAccount.Tests.ps1 => Remove-TeamViewerAccountFromRole.Tests.ps1} (86%) diff --git a/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 b/Cmdlets/Public/Remove-TeamViewerAccountFromRole.ps1 similarity index 97% rename from Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 rename to Cmdlets/Public/Remove-TeamViewerAccountFromRole.ps1 index d92e430..36efcfd 100644 --- a/Cmdlets/Public/Remove-TeamViewerRoleFromAccount.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerAccountFromRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerRoleFromAccount { +function Remove-TeamViewerAccountFromRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 4bc02cd..bc50aef 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Remove-TeamViewerRoleFromAccount.md b/Docs/Help/Remove-TeamViewerAccountFromRole.md similarity index 77% rename from Docs/Help/Remove-TeamViewerRoleFromAccount.md rename to Docs/Help/Remove-TeamViewerAccountFromRole.md index 1856e45..ab504f7 100644 --- a/Docs/Help/Remove-TeamViewerRoleFromAccount.md +++ b/Docs/Help/Remove-TeamViewerAccountFromRole.md @@ -1,53 +1,53 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerRoleFromAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerAccountFromRole.md schema: 2.0.0 --- -# Remove-TeamViewerRoleFromAccount +# Remove-TeamViewerAccountFromRole ## SYNOPSIS -Unassign role from a given list of accounts. +Unassign a given list of accounts from role. ## SYNTAX ### ByUserRoleIdMemberId (All) ```powershell -Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerAccountFromRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ### ByUserId ```powershell -Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerAccountFromRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Unassigns user role from one or many users. User role should belong to the TeamViewer company associated with the API access token. +Unassigns one or many users from user role. User role should belong to the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Remove-TeamViewerRoleFromAccount -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Remove-TeamViewerAccountFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` -Unassigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` from users with id `123`, `456`, `789`. +Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. ### Example 2 ```powershell -PS /> @('123', '456', '789') | Remove-TeamViewerRoleFromAccount -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Remove-TeamViewerAccountFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` -Unassigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` from users with id `123`, `456`, `789`. +Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. Ids are passed as pipeline input. ## PARAMETERS @@ -86,7 +86,7 @@ Accept wildcard characters: False ### -UserRoleId -The role from where users will be unassigned from. +The role where users will be unassigned from. ```yaml Type: Object diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index fa9c285..14bac5c 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -121,7 +121,7 @@ The following functions are available in this category: [`Add-TeamViewerUserGroupToRole`](Help/Add-TeamViewerAccountToRole) -[`Remove-TeamViewerRoleFromAccount`](Help/Remove-TeamviewerRoleFromAccount) +[`Remove-TeamViewerAccountFromRole`](Help/Remove-TeamViewerAccountFromRole) [`Remove-TeamViewerRoleFromUserroup`](Help/Remove-TeamViewerRoleFromUserGroup) diff --git a/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 similarity index 86% rename from Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 rename to Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 index 7666224..f25ced2 100644 --- a/Tests/Public/Remove-TeamViewerRoleFromAccount.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerRoleFromAccount.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerAccountFromRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -19,10 +19,10 @@ BeforeAll { } } } -Describe 'Remove-TeamViewerRoleFromAccount' { +Describe 'Remove-TeamViewerAccountFromRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerRoleFromAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Remove-TeamViewerAccountFromRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -32,7 +32,7 @@ Describe 'Remove-TeamViewerRoleFromAccount' { } It 'Should unassign the given account from the user role' { - Remove-TeamViewerRoleFromAccount ` + Remove-TeamViewerAccountFromRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId ` -Accounts $testAccount @@ -46,7 +46,7 @@ Describe 'Remove-TeamViewerRoleFromAccount' { } It 'Should accept pipeline input' { - $testAccount | Remove-TeamViewerRoleFromAccount ` + $testAccount | Remove-TeamViewerAccountFromRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty From 9d9957499596b1825210808bb1a08ad0c38ecc04 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Tue, 17 Oct 2023 23:37:56 +0200 Subject: [PATCH 073/110] Renames Remove-TeamViewerRoleFromUserGroup --- ...erGroup.ps1 => Remove-TeamViewerUserGroupFromRole.ps1} | 4 ++-- Cmdlets/TeamViewerPS.psd1 | 2 +- ...UserGroup.md => Remove-TeamViewerUserGroupFromRole.md} | 6 +++--- Docs/TeamViewerPS.md | 2 +- ...s.ps1 => Remove-TeamViewerUserGroupFromRole.Tests.ps1} | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) rename Cmdlets/Public/{Remove-TeamViewerRoleFromUserGroup.ps1 => Remove-TeamViewerUserGroupFromRole.ps1} (88%) rename Docs/Help/{Remove-TeamViewerRoleFromUserGroup.md => Remove-TeamViewerUserGroupFromRole.md} (91%) rename Tests/Public/{Remove-TeamViewerRoleFromUserGroup.Tests.ps1 => Remove-TeamViewerUserGroupFromRole.Tests.ps1} (83%) diff --git a/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 b/Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 similarity index 88% rename from Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 index 1f53745..70619b6 100644 --- a/Cmdlets/Public/Remove-TeamViewerRoleFromUserGroup.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerRoleFromUserGroup { +function Remove-TeamViewerUserGroupFromRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] @@ -23,7 +23,7 @@ function Remove-TeamViewerRoleFromUserGroup { Process { - if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign Role from User Group')) { + if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign User Group from Role')) { $result = Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index bc50aef..14f3405 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Remove-TeamViewerRoleFromUserGroup.md b/Docs/Help/Remove-TeamViewerUserGroupFromRole.md similarity index 91% rename from Docs/Help/Remove-TeamViewerRoleFromUserGroup.md rename to Docs/Help/Remove-TeamViewerUserGroupFromRole.md index 685dc3c..cc12ad0 100644 --- a/Docs/Help/Remove-TeamViewerRoleFromUserGroup.md +++ b/Docs/Help/Remove-TeamViewerUserGroupFromRole.md @@ -1,7 +1,7 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerRoleFromUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroupFromRole.md schema: 2.0.0 --- @@ -9,7 +9,7 @@ schema: 2.0.0 ## SYNOPSIS -Unassign user role from a user group. +Unassign a user group from a role. ## SYNTAX @@ -20,7 +20,7 @@ Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserGroup] Date: Wed, 18 Oct 2023 00:19:32 +0200 Subject: [PATCH 074/110] Renames Add-TeamViewerRoleToAccount --- CHANGELOG.md | 10 ++--- ...s1 => Add-TeamViewerAccountToUserRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ....md => Add-TeamViewerAccountToUserRole.md} | 10 ++--- Docs/TeamViewerPS.md | 41 +++++++++---------- ...Add-TeamViewerAccountToUserRole.Tests.ps1} | 10 ++--- 6 files changed, 36 insertions(+), 39 deletions(-) rename Cmdlets/Public/{Add-TeamViewerAccountToRole.ps1 => Add-TeamViewerAccountToUserRole.ps1} (97%) rename Docs/Help/{Add-TeamViewerAccountToRole.md => Add-TeamViewerAccountToUserRole.md} (84%) rename Tests/Public/{Add-TeamViewerAccountToRole.Tests.ps1 => Add-TeamViewerAccountToUserRole.Tests.ps1} (87%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b7a0ba..7a20a6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # Change Log -## 2.0.0 (2023-09-13) +## 2.0.0 (2023-10-xx) ### Added -- Adds user role commands to manage user roles of a TeamViewer company. +- Adds commands to manage the user roles of a TeamViewer company. - Adds `Set-TeamViewerApiURi` to use TeamViewer test API. - Adds `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. - Adds `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. @@ -12,16 +12,16 @@ - Adds `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. - Adds `Get-TeamViewerInstallationDirectory` to return installation directory. - Adds `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. - + ### Changed - + - Extends `Invoke-TeamViewerPackageDownload` with MSI package type. - Removes `-RemovePolicy` switch from `Set-TeamViewerManagedDevice`. - Removes `-Permissions` switch from `Get-TeamViewerUser`, `New-TeamViewerUser` and `Remove-TeamViewerUser`. - Modifies general module folder structure. ### Fixed - + - Fixes `Get-TeamViewerLinuxGlobalConfig` to handle null values. ## 1.5.2 (2023-09-18) diff --git a/Cmdlets/Public/Add-TeamViewerAccountToRole.ps1 b/Cmdlets/Public/Add-TeamViewerAccountToUserRole.ps1 similarity index 97% rename from Cmdlets/Public/Add-TeamViewerAccountToRole.ps1 rename to Cmdlets/Public/Add-TeamViewerAccountToUserRole.ps1 index ac9e56d..1edea85 100644 --- a/Cmdlets/Public/Add-TeamViewerAccountToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerAccountToUserRole.ps1 @@ -1,4 +1,4 @@ -function Add-TeamViewerAccountToRole { +function Add-TeamViewerAccountToUserRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 14f3405..10acb8a 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Add-TeamViewerAccountToRole.md b/Docs/Help/Add-TeamViewerAccountToUserRole.md similarity index 84% rename from Docs/Help/Add-TeamViewerAccountToRole.md rename to Docs/Help/Add-TeamViewerAccountToUserRole.md index a7a70fb..24cc24d 100644 --- a/Docs/Help/Add-TeamViewerAccountToRole.md +++ b/Docs/Help/Add-TeamViewerAccountToUserRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerAccountToRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerAccountToUserRole.md schema: 2.0.0 --- -# Add-TeamViewerAccountToRole +# Add-TeamViewerAccountToUserRole ## SYNOPSIS @@ -14,7 +14,7 @@ Assign user role to a list of accountIds. ## SYNTAX ```powershell -Add-TeamViewerAccountToRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] +Add-TeamViewerAccountToUserRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Assigns user role to one or many users. User role should belong to the TeamViewe ### Example 1 ```powershell -PS /> Add-TeamViewerAccountToRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Add-TeamViewerAccountToUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. @@ -35,7 +35,7 @@ Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `12 ### Example 2 ```powershell -PS /> @('123', '456', '789') | Add-TeamViewerAccountToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Add-TeamViewerAccountToUserRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index 805dc7d..dcf5612 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -2,13 +2,11 @@ # SHORT DESCRIPTION -TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally -installed TeamViewer client. +Interact with the TeamViewer Web API as well as a locally installed TeamViewer client. # LONG DESCRIPTION -TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally -installed TeamViewer client. +TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally installed TeamViewer client. The module provides functions for the following categories: @@ -30,9 +28,9 @@ Manage customization of the locally installed TeamViewer Client. [`Remove-TeamViewerCustomization`](Help/Remove-TeamViewerCustomization.md) -## Computers & Contacts list +## Computers & Contacts -Remotely manage the Computers & Contacts list via the TeamViewer Web API. +Remotely manage the Computers & Contacts via the TeamViewer Web API. The following functions are available in this category: @@ -62,7 +60,7 @@ The following functions are available in this category: [`Unpublish-TeamViewerGroup`](Help/Unpublish-TeamViewerGroup.md) -## User management +## User Management Remotely manage the user accounts of a TeamViewer company via the TeamViewer Web API. @@ -77,7 +75,7 @@ The following functions are available in this category: [`Set-TeamViewerUser`](Help/Set-TeamViewerUser.md) -## User groups +## User Groups Remotely manage the user groups of a TeamViewer company via the TeamViewer Web API. Have user groups to organize company members. @@ -98,7 +96,7 @@ The following functions are available in this category: [`Remove-TeamViewerUserGroupMember`](Help/Remove-TeamViewerUserGroupMember.md) -## Role Management +## User Roles Remotely manage the user roles of a TeamViewer company via the TeamViewer Web API. Have user roles to assign roles to company members. @@ -117,18 +115,17 @@ The following functions are available in this category: [`Get-TeamViewerRoleAssignmentToUserGroup`](Help/Get-TeamViewerRoleAssignmentToUserGroup.md) -[`Add-TeamViewerAccountToRole`](Help/Add-TeamViewerAccountToRole) +[`Add-TeamViewerAccountToUserRole`](Help/Add-TeamViewerAccountToUserRole) -[`Add-TeamViewerUserGroupToRole`](Help/Add-TeamViewerAccountToRole) +[`Add-TeamViewerUserGroupToRole`](Help/Add-TeamViewerAccountToUserRole) [`Remove-TeamViewerAccountFromRole`](Help/Remove-TeamViewerAccountFromRole) -[`Remove-TeamViewerRoleFromUserroup`](Help/Remove-TeamViewerUserGroupFromRole) +[`Remove-TeamViewerRoleFromUserGroup`](Help/Remove-TeamViewerUserGroupFromRole) -## Managed groups +## Managed Groups & Managed Devices -Remotely manage the managed groups and managed devices of an account via the -TeamViewer Web API. +Remotely manage the managed groups and managed devices of an account via the TeamViewer Web API. The following functions are available in this category: @@ -162,7 +159,7 @@ The following functions are available in this category: [`Remove-TeamViewerPolicyFromManagedDevice`](Cmdlets/Pulic/Remove-TeamViewerpolicyFromManagedDevice.md) -## Policy management +## Policy Management Remotely manage the policies of a TeamViewer company via the TeamViewer Web API. @@ -176,7 +173,7 @@ The following functions are available in this category: [`Set-TeamViewerPolicy`](Help/Set-TeamViewerPolicy.md) -## Single Sign-On management +## Single Sign-On (SSO) Management Remotely manage Single Sign-On configurations via the TeamViewer Web API. @@ -190,7 +187,7 @@ The following functions are available in this category: [`Remove-TeamViewerSsoExclusion`](Help/Remove-TeamViewerSsoExclusion.md) -## Event logs & reporting +## Event Logs & Reporting Retrieve event log entries or connection-reports of a TeamViewer company via the TeamViewer Web API. @@ -199,9 +196,9 @@ API. [`Get-TeamViewerEventLog`](Help/Get-TeamViewerEventLog.md) -## Local TeamViewer utilities +## Local Client Utilities -Utilities that help managing the local TeamViewer installation. +Utilities that help managing the local TeamViewer client. The following functions are available in this category: @@ -229,7 +226,7 @@ The following functions are available in this category: [`Test-TeamViewerInstallation`](Help/Test-TeamViewerInstallation.md) -## Web API utilities +## Web API Utilities Utilities that help working with the TeamViewer Web API related functions. @@ -243,7 +240,7 @@ The following functions are available in this category: ## Web API proxy -Functions that manage proxy when working with TeamViewer Web API reated functions. +Functions that manage proxy when working with TeamViewer Web API related functions. The following functions are available in this category: diff --git a/Tests/Public/Add-TeamViewerAccountToRole.Tests.ps1 b/Tests/Public/Add-TeamViewerAccountToUserRole.Tests.ps1 similarity index 87% rename from Tests/Public/Add-TeamViewerAccountToRole.Tests.ps1 rename to Tests/Public/Add-TeamViewerAccountToUserRole.Tests.ps1 index 93b634a..6b76774 100644 --- a/Tests/Public/Add-TeamViewerAccountToRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerAccountToUserRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerAccountToRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerAccountToUserRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -19,10 +19,10 @@ BeforeAll { } } } -Describe 'Add-TeamViewerAccountToRole' { +Describe 'Add-TeamViewerAccountToUserRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerAccountToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Add-TeamViewerAccountToUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -33,7 +33,7 @@ Describe 'Add-TeamViewerAccountToRole' { It 'Should assign the given account to the user role' { - Add-TeamViewerAccountToRole ` + Add-TeamViewerAccountToUserRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId ` -Accounts $testAccount @@ -47,7 +47,7 @@ Describe 'Add-TeamViewerAccountToRole' { } It 'Should accept pipeline input' { - $testAccount | Add-TeamViewerAccountToRole ` + $testAccount | Add-TeamViewerAccountToUserRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty From 5b089068cefa13b40d560aee7421ead58c171c1e Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:22:25 +0200 Subject: [PATCH 075/110] Renames Add-TeamViewerRoleToUserGroup --- ...upToRole.ps1 => Add-TeamViewerUserGroupToUserRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ...roupToRole.md => Add-TeamViewerUserGroupToUserRole.md} | 8 ++++---- Docs/TeamViewerPS.md | 2 +- ...ts.ps1 => Add-TeamViewerUserGroupToUserRole.Tests.ps1} | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) rename Cmdlets/Public/{Add-TeamViewerUserGroupToRole.ps1 => Add-TeamViewerUserGroupToUserRole.ps1} (96%) rename Docs/Help/{Add-TeamViewerUserGroupToRole.md => Add-TeamViewerUserGroupToUserRole.md} (87%) rename Tests/Public/{Add-TeamViewerUserGroupToRole.Tests.ps1 => Add-TeamViewerUserGroupToUserRole.Tests.ps1} (85%) diff --git a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupToUserRole.ps1 similarity index 96% rename from Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 rename to Cmdlets/Public/Add-TeamViewerUserGroupToUserRole.ps1 index 93aacea..9100816 100644 --- a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserGroupToUserRole.ps1 @@ -1,4 +1,4 @@ -function Add-TeamViewerUserGroupToRole { +function Add-TeamViewerUserGroupToUserRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 10acb8a..2a27ab5 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToUserRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Add-TeamViewerUserGroupToRole.md b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md similarity index 87% rename from Docs/Help/Add-TeamViewerUserGroupToRole.md rename to Docs/Help/Add-TeamViewerUserGroupToUserRole.md index dd4ce4a..f38ef06 100644 --- a/Docs/Help/Add-TeamViewerUserGroupToRole.md +++ b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserGroupToRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserGroupToUserRole.md schema: 2.0.0 --- -# Add-TeamViewerUserGroupToRole +# Add-TeamViewerUserGroupToUserRole ## SYNOPSIS @@ -14,7 +14,7 @@ Assign user role to a user group. ## SYNTAX ```powershell -Add-TeamViewerUserGroupToRole [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] +Add-TeamViewerUserGroupToUserRole [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Assigns user role to a user group of the TeamViewer company associated with the ### Example 1 ```powershell -PS /> Add-TeamViewerUserGroupToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 +PS /> Add-TeamViewerUserGroupToUserRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 ``` The given user group `1001` gets assigned to the user role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index dcf5612..37bb78c 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -117,7 +117,7 @@ The following functions are available in this category: [`Add-TeamViewerAccountToUserRole`](Help/Add-TeamViewerAccountToUserRole) -[`Add-TeamViewerUserGroupToRole`](Help/Add-TeamViewerAccountToUserRole) +[`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerAccountToUserRole) [`Remove-TeamViewerAccountFromRole`](Help/Remove-TeamViewerAccountFromRole) diff --git a/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupToUserRole.Tests.ps1 similarity index 85% rename from Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 rename to Tests/Public/Add-TeamViewerUserGroupToUserRole.Tests.ps1 index ba0e965..a571247 100644 --- a/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupToUserRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserGroupToRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserGroupToUserRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -18,9 +18,9 @@ BeforeAll { } } } -Describe 'Add-TeamViewerUserGroupToRole' { +Describe 'Add-TeamViewerUserGroupToUserRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerUserGroupToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Add-TeamViewerUserGroupToUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` From b5623abfbe949d6c4b8f68b329aaca9a958e6c07 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:26:58 +0200 Subject: [PATCH 076/110] Renames Remove-TeamViewerRoleFromAccount --- ...ole.ps1 => Remove-TeamViewerUserGroupFromUserRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ...mRole.md => Remove-TeamViewerUserGroupFromUserRole.md} | 8 ++++---- Docs/TeamViewerPS.md | 2 +- ...1 => Remove-TeamViewerUserGroupFromUserRole.Tests.ps1} | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) rename Cmdlets/Public/{Remove-TeamViewerUserGroupFromRole.ps1 => Remove-TeamViewerUserGroupFromUserRole.ps1} (95%) rename Docs/Help/{Remove-TeamViewerUserGroupFromRole.md => Remove-TeamViewerUserGroupFromUserRole.md} (88%) rename Tests/Public/{Remove-TeamViewerUserGroupFromRole.Tests.ps1 => Remove-TeamViewerUserGroupFromUserRole.Tests.ps1} (84%) diff --git a/Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 similarity index 95% rename from Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 index 70619b6..eab32c2 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerUserGroupFromRole { +function Remove-TeamViewerUserGroupFromUserRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 2a27ab5..862cfd3 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToUserRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToUserRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromUserRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Remove-TeamViewerUserGroupFromRole.md b/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md similarity index 88% rename from Docs/Help/Remove-TeamViewerUserGroupFromRole.md rename to Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md index cc12ad0..ada5968 100644 --- a/Docs/Help/Remove-TeamViewerUserGroupFromRole.md +++ b/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroupFromRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md schema: 2.0.0 --- -# Remove-TeamViewerRoleFromAccount +# Remove-TeamViewerAccountFromUserRole ## SYNOPSIS @@ -14,7 +14,7 @@ Unassign a user group from a role. ## SYNTAX ```powershell -Remove-TeamViewerRoleFromAccount [-ApiToken] [-UserGroup] [-WhatIf] +Remove-TeamViewerAccountFromUserRole [-ApiToken] [-UserGroup] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Unassigns user group from a role of the TeamViewer company associated with the A ### Example 1 ```powershell -PS /> Remove-TeamViewerRoleFromAccount -UserGroup 1001 +PS /> Remove-TeamViewerAccountFromUserRole -UserGroup 1001 ``` The given user group `1001` gets unassigned from its user role. diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index 37bb78c..e2bd8f0 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -121,7 +121,7 @@ The following functions are available in this category: [`Remove-TeamViewerAccountFromRole`](Help/Remove-TeamViewerAccountFromRole) -[`Remove-TeamViewerRoleFromUserGroup`](Help/Remove-TeamViewerUserGroupFromRole) +[`Remove-TeamViewerRoleFromUserGroup`](Help/Remove-TeamViewerUserGroupFromUserRole) ## Managed Groups & Managed Devices diff --git a/Tests/Public/Remove-TeamViewerUserGroupFromRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 similarity index 84% rename from Tests/Public/Remove-TeamViewerUserGroupFromRole.Tests.ps1 rename to Tests/Public/Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 index 6d5d89b..b2a42bb 100644 --- a/Tests/Public/Remove-TeamViewerUserGroupFromRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserGroupFromRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserGroupFromUserRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -17,10 +17,10 @@ BeforeAll { } } } -Describe 'Remove-TeamViewerUserGroupFromRole' { +Describe 'Remove-TeamViewerUserGroupFromUserRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerUserGroupFromRole -ApiToken $testApiToken -UserGroup $testUserGroup + Remove-TeamViewerUserGroupFromUserRole -ApiToken $testApiToken -UserGroup $testUserGroup Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -30,7 +30,7 @@ Describe 'Remove-TeamViewerUserGroupFromRole' { } It 'Should unassign the given user group from the user role' { - Remove-TeamViewerUserGroupFromRole ` + Remove-TeamViewerUserGroupFromUserRole ` -ApiToken $testApiToken ` -UserGroup $testUserGroup $mockArgs.Body | Should -Not -BeNullOrEmpty From 8ac32874d8afe560bba209294f8f3c58176b8536 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:29:25 +0200 Subject: [PATCH 077/110] Remove-TeamViewerRoleFromUserGroup --- Docs/TeamViewerPS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index e2bd8f0..ae620ec 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -121,7 +121,7 @@ The following functions are available in this category: [`Remove-TeamViewerAccountFromRole`](Help/Remove-TeamViewerAccountFromRole) -[`Remove-TeamViewerRoleFromUserGroup`](Help/Remove-TeamViewerUserGroupFromUserRole) +[`Remove-TeamViewerUserGroupFromUserRole`](Help/Remove-TeamViewerUserGroupFromUserRole) ## Managed Groups & Managed Devices From dc8393c1929863b9cd4ee519021aadf9d7acaa7c Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:36:16 +0200 Subject: [PATCH 078/110] Role to User Role --- ....ps1 => Remove-TeamViewerAccountFromUserRole.ps1} | 2 +- Cmdlets/TeamViewerPS.psd1 | 2 +- ...le.md => Remove-TeamViewerAccountFromUserRole.md} | 12 ++++++------ Docs/TeamViewerPS.md | 2 +- ...> Remove-TeamViewerAccountFromUserRole.Tests.ps1} | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) rename Cmdlets/Public/{Remove-TeamViewerAccountFromRole.ps1 => Remove-TeamViewerAccountFromUserRole.ps1} (97%) rename Docs/Help/{Remove-TeamViewerAccountFromRole.md => Remove-TeamViewerAccountFromUserRole.md} (82%) rename Tests/Public/{Remove-TeamViewerAccountFromRole.Tests.ps1 => Remove-TeamViewerAccountFromUserRole.Tests.ps1} (86%) diff --git a/Cmdlets/Public/Remove-TeamViewerAccountFromRole.ps1 b/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 similarity index 97% rename from Cmdlets/Public/Remove-TeamViewerAccountFromRole.ps1 rename to Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 index 36efcfd..61ae1a7 100644 --- a/Cmdlets/Public/Remove-TeamViewerAccountFromRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerAccountFromRole { +function Remove-TeamViewerAccountFromUserRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 862cfd3..0b9a198 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToUserRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromRole', 'Remove-TeamViewerUserGroupFromUserRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerAccountToUserRole', 'Add-TeamViewerUserGroupToUserRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerAccountFromUserRole', 'Remove-TeamViewerUserGroupFromUserRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Remove-TeamViewerAccountFromRole.md b/Docs/Help/Remove-TeamViewerAccountFromUserRole.md similarity index 82% rename from Docs/Help/Remove-TeamViewerAccountFromRole.md rename to Docs/Help/Remove-TeamViewerAccountFromUserRole.md index ab504f7..3d665ee 100644 --- a/Docs/Help/Remove-TeamViewerAccountFromRole.md +++ b/Docs/Help/Remove-TeamViewerAccountFromUserRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerAccountFromRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerAccountFromUserRole.md schema: 2.0.0 --- -# Remove-TeamViewerAccountFromRole +# Remove-TeamViewerAccountFromUserRole ## SYNOPSIS @@ -16,14 +16,14 @@ Unassign a given list of accounts from role. ### ByUserRoleIdMemberId (All) ```powershell -Remove-TeamViewerAccountFromRole [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerAccountFromUserRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ### ByUserId ```powershell -Remove-TeamViewerAccountFromRole [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerAccountFromUserRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` @@ -36,7 +36,7 @@ Unassigns one or many users from user role. User role should belong to the TeamV ### Example 1 ```powershell -PS /> Remove-TeamViewerAccountFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Remove-TeamViewerAccountFromUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. @@ -44,7 +44,7 @@ Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-410 ### Example 2 ```powershell -PS /> @('123', '456', '789') | Remove-TeamViewerAccountFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Remove-TeamViewerAccountFromUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index ae620ec..1714b37 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -119,7 +119,7 @@ The following functions are available in this category: [`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerAccountToUserRole) -[`Remove-TeamViewerAccountFromRole`](Help/Remove-TeamViewerAccountFromRole) +[`Remove-TeamViewerAccountFromUserRole`](Help/Remove-TeamViewerAccountFromUserRole) [`Remove-TeamViewerUserGroupFromUserRole`](Help/Remove-TeamViewerUserGroupFromUserRole) diff --git a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerAccountFromUserRole.Tests.ps1 similarity index 86% rename from Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 rename to Tests/Public/Remove-TeamViewerAccountFromUserRole.Tests.ps1 index f25ced2..6d544ae 100644 --- a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerAccountFromUserRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerAccountFromRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerAccountFromUserRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -19,10 +19,10 @@ BeforeAll { } } } -Describe 'Remove-TeamViewerAccountFromRole' { +Describe 'Remove-TeamViewerAccountFromUserRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerAccountFromRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Remove-TeamViewerAccountFromUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -32,7 +32,7 @@ Describe 'Remove-TeamViewerAccountFromRole' { } It 'Should unassign the given account from the user role' { - Remove-TeamViewerAccountFromRole ` + Remove-TeamViewerAccountFromUserRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId ` -Accounts $testAccount @@ -46,7 +46,7 @@ Describe 'Remove-TeamViewerAccountFromRole' { } It 'Should accept pipeline input' { - $testAccount | Remove-TeamViewerAccountFromRole ` + $testAccount | Remove-TeamViewerAccountFromUserRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty From fdd30c067c0b1f26a5188b757a6023bcbfe0a812 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:40:43 +0200 Subject: [PATCH 079/110] role to user role --- Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 | 2 +- Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 | 2 +- Docs/Help/Remove-TeamViewerAccountFromUserRole.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 b/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 index 61ae1a7..99455b5 100644 --- a/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 @@ -41,7 +41,7 @@ function Remove-TeamViewerAccountFromUserRole { } Process { - if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from Role')) { + if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from user role')) { if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } } diff --git a/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 index eab32c2..1512fe2 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 @@ -23,7 +23,7 @@ function Remove-TeamViewerUserGroupFromUserRole { Process { - if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign User Group from Role')) { + if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign User Group from user role')) { $result = Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` diff --git a/Docs/Help/Remove-TeamViewerAccountFromUserRole.md b/Docs/Help/Remove-TeamViewerAccountFromUserRole.md index 3d665ee..b5d0aec 100644 --- a/Docs/Help/Remove-TeamViewerAccountFromUserRole.md +++ b/Docs/Help/Remove-TeamViewerAccountFromUserRole.md @@ -9,7 +9,7 @@ schema: 2.0.0 ## SYNOPSIS -Unassign a given list of accounts from role. +Unassign a given list of accounts from user role. ## SYNTAX @@ -39,7 +39,7 @@ Unassigns one or many users from user role. User role should belong to the TeamV PS /> Remove-TeamViewerAccountFromUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` -Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. +Unassigns users with id `123`, `456`, `789` from user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. ### Example 2 @@ -47,7 +47,7 @@ Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-410 PS /> @('123', '456', '789') | Remove-TeamViewerAccountFromUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` -Unassigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. +Unassigns users with id `123`, `456`, `789` from user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. Ids are passed as pipeline input. ## PARAMETERS From 1773ea886dcaaf30faf5d2ebf8bddad539fc8c80 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:45:20 +0200 Subject: [PATCH 080/110] role to user role 3rd --- Docs/Help/Add-TeamViewerAccountToUserRole.md | 2 +- Docs/Help/Add-TeamViewerUserGroupToUserRole.md | 4 ++-- Docs/Help/New-TeamViewerUserRole.md | 4 ++-- Docs/Help/Remove-TeamViewerAccountFromUserRole.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Docs/Help/Add-TeamViewerAccountToUserRole.md b/Docs/Help/Add-TeamViewerAccountToUserRole.md index 24cc24d..b90b954 100644 --- a/Docs/Help/Add-TeamViewerAccountToUserRole.md +++ b/Docs/Help/Add-TeamViewerAccountToUserRole.md @@ -77,7 +77,7 @@ Accept wildcard characters: False ### -UserRoleId -The role to which users will be assigned to. +the user role to which users will be assigned to. ```yaml Type: Object diff --git a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md index f38ef06..edd1472 100644 --- a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md +++ b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md @@ -68,7 +68,7 @@ Accept wildcard characters: False ### -UserRole -The role to be assigned to the accountIds +The user role to be assigned to the accountIds ```yaml Type: Object @@ -84,7 +84,7 @@ Accept wildcard characters: False ### -UserGroup -The user group to which the role should be assigned. +The user group to which the user role should be assigned. ```yaml Type: Object diff --git a/Docs/Help/New-TeamViewerUserRole.md b/Docs/Help/New-TeamViewerUserRole.md index 766ebe1..6f482c2 100644 --- a/Docs/Help/New-TeamViewerUserRole.md +++ b/Docs/Help/New-TeamViewerUserRole.md @@ -20,7 +20,7 @@ New-TeamViewerUserRole [-ApiToken] [-Name] [-Permissions ## DESCRIPTION Create a new user role that belongs to the TeamViewer company associated with the API access token. -The name of the new user role should be unique among the roles of the TeamViewer Company. +The name of the new user role should be unique among the user roles of the TeamViewer Company. ## EXAMPLES @@ -40,7 +40,7 @@ PS /> New-TeamViewerUserRole -Name 'New user role' ``` Creates a new user role with name `New user role` without any permissions. -The name should be unique among the roles of the TeamViewer Company. +The name should be unique among the user roles of the TeamViewer Company. ## PARAMETERS diff --git a/Docs/Help/Remove-TeamViewerAccountFromUserRole.md b/Docs/Help/Remove-TeamViewerAccountFromUserRole.md index b5d0aec..7af8438 100644 --- a/Docs/Help/Remove-TeamViewerAccountFromUserRole.md +++ b/Docs/Help/Remove-TeamViewerAccountFromUserRole.md @@ -86,7 +86,7 @@ Accept wildcard characters: False ### -UserRoleId -The role where users will be unassigned from. +The user role where users will be unassigned from. ```yaml Type: Object From d7976edcd1d39883aad3dd091246b41a85610335 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 18 Oct 2023 00:52:08 +0200 Subject: [PATCH 081/110] Corrects help text --- Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md b/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md index ada5968..585ed91 100644 --- a/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md @@ -5,29 +5,29 @@ online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/R schema: 2.0.0 --- -# Remove-TeamViewerAccountFromUserRole +# Remove-TeamViewerUserGroupFromUserRole ## SYNOPSIS -Unassign a user group from a role. +Unassign a user group from a user role. ## SYNTAX ```powershell -Remove-TeamViewerAccountFromUserRole [-ApiToken] [-UserGroup] [-WhatIf] +Remove-TeamViewerUserGroupFromUserRole [-ApiToken] [-UserGroup] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Unassigns user group from a role of the TeamViewer company associated with the API access token. +Unassigns user group from a user role of the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Remove-TeamViewerAccountFromUserRole -UserGroup 1001 +PS /> Remove-TeamViewerUserGroupFromUserRole -UserGroup 1001 ``` The given user group `1001` gets unassigned from its user role. From 39669a21fe7cab8297c2112724bc4e65a5b5da1d Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:42:36 +0200 Subject: [PATCH 082/110] Update TeamViewerPS.md Adds ".md" to fix urls --- Docs/TeamViewerPS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index 1714b37..6f9ac36 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -115,13 +115,13 @@ The following functions are available in this category: [`Get-TeamViewerRoleAssignmentToUserGroup`](Help/Get-TeamViewerRoleAssignmentToUserGroup.md) -[`Add-TeamViewerAccountToUserRole`](Help/Add-TeamViewerAccountToUserRole) +[`Add-TeamViewerAccountToUserRole`](Help/Add-TeamViewerAccountToUserRole.md) -[`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerAccountToUserRole) +[`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerAccountToUserRole.md) -[`Remove-TeamViewerAccountFromUserRole`](Help/Remove-TeamViewerAccountFromUserRole) +[`Remove-TeamViewerAccountFromUserRole`](Help/Remove-TeamViewerAccountFromUserRole.md) -[`Remove-TeamViewerUserGroupFromUserRole`](Help/Remove-TeamViewerUserGroupFromUserRole) +[`Remove-TeamViewerUserGroupFromUserRole`](Help/Remove-TeamViewerUserGroupFromUserRole.md) ## Managed Groups & Managed Devices From ffa278581590d2a7b34190c7bd14e9e5d2806eef Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:44:54 +0200 Subject: [PATCH 083/110] Update TeamViewerPS.md Fixed link --- Docs/TeamViewerPS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index 6f9ac36..4135def 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -111,7 +111,7 @@ The following functions are available in this category: [`Remove-TeamViewerUserRole`](Help/Remove-TeamViewerUserRole.md) -[`Get-TeamViewerRoleAssignmentToAccount`](Help/Get-TeamviewerRoleAssignmentToAccount.md) +[`Get-TeamViewerRoleAssignmentToAccount`](Help/Get-TeamViewerRoleAssignmentToAccount.md) [`Get-TeamViewerRoleAssignmentToUserGroup`](Help/Get-TeamViewerRoleAssignmentToUserGroup.md) From 52db1641e949c71a5829dcf56f7f7103f73683e5 Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:47:42 +0200 Subject: [PATCH 084/110] Update TeamViewerPS.md --- Docs/TeamViewerPS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index 4135def..963d583 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -117,7 +117,7 @@ The following functions are available in this category: [`Add-TeamViewerAccountToUserRole`](Help/Add-TeamViewerAccountToUserRole.md) -[`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerAccountToUserRole.md) +[`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerUserGroupToUserRole.md) [`Remove-TeamViewerAccountFromUserRole`](Help/Remove-TeamViewerAccountFromUserRole.md) From a973477d5ffe426d2cc6f9053e4458a4cc220f6a Mon Sep 17 00:00:00 2001 From: "Christian J. (TV)" <45047468+ChristianJ-TV@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:50:46 +0200 Subject: [PATCH 085/110] Update TeamViewerPS.md Fixed link --- Docs/TeamViewerPS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index 963d583..d0d10aa 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -157,7 +157,7 @@ The following functions are available in this category: [`Remove-TeamViewerManager`](Help/Remove-TeamViewerManager.md) -[`Remove-TeamViewerPolicyFromManagedDevice`](Cmdlets/Pulic/Remove-TeamViewerpolicyFromManagedDevice.md) +[`Remove-TeamViewerPolicyFromManagedDevice`](Cmdlets/Pulic/Remove-TeamViewerPolicyFromManagedDevice.md) ## Policy Management From 4e343162bf7fdf2defb0eb3a851ffee11c5c37e1 Mon Sep 17 00:00:00 2001 From: Karthick Gandhi Date: Fri, 20 Oct 2023 14:18:05 +0200 Subject: [PATCH 086/110] Predefined role management functions added --- Build/New-Package.ps1 | 2 +- .../ConvertTo-TeamViewerPredefinedRole.ps1 | 21 +++++ .../Private/Resolve-TeamViewerUserRoleId.ps1 | 2 +- .../Public/Get-TeamViewerPredefinedRole.ps1 | 25 ++++++ .../Remove-TeamViewerPredefinedRole.ps1 | 27 ++++++ .../Public/Set-TeamViewerPredefinedRole.ps1 | 29 ++++++ Cmdlets/TeamViewerPS.psd1 | 2 +- Docs/Help/Get-TeamViewerPredefinedRole.md | 76 ++++++++++++++++ Docs/Help/Remove-TeamViewerPredefinedRole.md | 66 ++++++++++++++ Docs/Help/Set-TeamViewerPredefinedRole.md | 88 +++++++++++++++++++ .../Get-TeamViewerPredefinedRole.Tests.ps1 | 46 ++++++++++ .../Remove-TeamViewerPredefinedRole.Tests.ps1 | 24 +++++ .../Set-TeamViewerPredefinedRole.Tests.ps1 | 27 ++++++ 13 files changed, 432 insertions(+), 3 deletions(-) create mode 100644 Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 create mode 100644 Cmdlets/Public/Get-TeamViewerPredefinedRole.ps1 create mode 100644 Cmdlets/Public/Remove-TeamViewerPredefinedRole.ps1 create mode 100644 Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 create mode 100644 Docs/Help/Get-TeamViewerPredefinedRole.md create mode 100644 Docs/Help/Remove-TeamViewerPredefinedRole.md create mode 100644 Docs/Help/Set-TeamViewerPredefinedRole.md create mode 100644 Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 create mode 100644 Tests/Public/Remove-TeamViewerPredefinedRole.Tests.ps1 create mode 100644 Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 diff --git a/Build/New-Package.ps1 b/Build/New-Package.ps1 index 10fe295..38c63f9 100644 --- a/Build/New-Package.ps1 +++ b/Build/New-Package.ps1 @@ -17,7 +17,7 @@ Write-Verbose 'Creating build output directories...' New-Item -Type Directory $Build_OutputPath | Out-Null # Compile all functions into a single psm file -$Build_ModulePath = (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.psm1') +$Build_ModulePath = (Join-Path -Path $Build_OutputPath -ChildPath 'TeamViewerPS.psm1') Write-Verbose 'Compiling single-file TeamViewer module...' $ModuleTypes = @(Get-ChildItem -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.Types.ps1')) diff --git a/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 new file mode 100644 index 0000000..f03befa --- /dev/null +++ b/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 @@ -0,0 +1,21 @@ +function ConvertTo-TeamViewerPredefinedRole { + param( + [Parameter(ValueFromPipeline = $true)] + [PSObject] + $InputObject + ) + process { + if($InputObject){ + $properties = @{ + PredefinedRoleId = $InputObject.PredefineduserRoleId + } + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.PredefinedRole') + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "[$($this.PredefinedRoleID)]" + } + Write-Output $result + } +} diff --git a/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 index 7ed22bc..09b268e 100644 --- a/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 +++ b/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 @@ -2,7 +2,7 @@ function Resolve-TeamViewerUserRoleId { param( [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] + [Object] $UserRole ) Process { diff --git a/Cmdlets/Public/Get-TeamViewerPredefinedRole.ps1 b/Cmdlets/Public/Get-TeamViewerPredefinedRole.ps1 new file mode 100644 index 0000000..c5c5428 --- /dev/null +++ b/Cmdlets/Public/Get-TeamViewerPredefinedRole.ps1 @@ -0,0 +1,25 @@ +function Get-TeamViewerPredefinedRole { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + + Begin { + $parameters = @{} + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/predefined" + } + + Process { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerPredefinedRole) + + } +} diff --git a/Cmdlets/Public/Remove-TeamViewerPredefinedRole.ps1 b/Cmdlets/Public/Remove-TeamViewerPredefinedRole.ps1 new file mode 100644 index 0000000..652bccb --- /dev/null +++ b/Cmdlets/Public/Remove-TeamViewerPredefinedRole.ps1 @@ -0,0 +1,27 @@ +function Remove-TeamViewerPredefinedRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + + Begin { + $parameters = @{} + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/predefined" + } + + Process { + if ($PSCmdlet.ShouldProcess('PredefinedRole', 'Remove Predefined role')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method DELETE ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} diff --git a/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 b/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 new file mode 100644 index 0000000..88376a5 --- /dev/null +++ b/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 @@ -0,0 +1,29 @@ +function Set-TeamViewerPredefinedRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true )] + [ValidateScript({ $_ | Resolve-TeamViewerUserRoleId })] + [object] + $RoleId + ) + + Process { + $Role = $RoleId | Resolve-TeamViewerUserRoleId + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/$Role/predefined" + if ($PSCmdlet.ShouldProcess($Role, 'Set Predefined Role')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } + +} diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 3e6c9d8..286d965 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerRoleToAccount', 'Add-TeamViewerRoleToUserGroup', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerRoleAssignmentToAccount', 'Get-TeamViewerRoleAssignmentToUserGroup', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerUserRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerUserRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerRoleFromAccount', 'Remove-TeamViewerRoleFromUserGroup', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerUserRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerUserRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerPredefinedRole','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPredefinedRole','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Resolve-TeamViewerUserRoleId','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPredefinedRole','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Get-TeamViewerPredefinedRole.md b/Docs/Help/Get-TeamViewerPredefinedRole.md new file mode 100644 index 0000000..14478c9 --- /dev/null +++ b/Docs/Help/Get-TeamViewerPredefinedRole.md @@ -0,0 +1,76 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerPredefinedRole.md +schema: 2.0.0 +--- + +# Get-TeamViewerPredefinedRole + +## SYNOPSIS + +Retrieve the Predefine Role in a TeamViewer company. + +## SYNTAX + +```powershell +Get-TeamViewerPredefinedRole [-ApiToken] [] +``` + +## DESCRIPTION + +Retrieves the Predefined role among the existing roles in the TeamViewer company associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Get-TeamViewerPredefinedRole +``` + +Retrieves the Predefined Role ID. + +### Example 2 + +```powershell +PS /> forEach-Object { Get-TeamViewerUserRole | Where-Object { $_.RoleID -eq (Get-TeamViewerPredefinedRole).PredefinedRoleID } } +``` + +Retrieves the complete information about the predefined role. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 + +An array of `TeamViewerPS.PredefinedRole` objects. + +## NOTES + +## RELATED LINKS diff --git a/Docs/Help/Remove-TeamViewerPredefinedRole.md b/Docs/Help/Remove-TeamViewerPredefinedRole.md new file mode 100644 index 0000000..69bfeea --- /dev/null +++ b/Docs/Help/Remove-TeamViewerPredefinedRole.md @@ -0,0 +1,66 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerPredefinedRole.md +schema: 2.0.0 +--- + +# Remove-TeamViewerPredefinedRole + +## SYNOPSIS + +Remove existing Predefined Role. + +## SYNTAX + +```powershell +Remove-TeamViewerPredefinedRole [-ApiToken] [-UserRoleId] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION + +Sets the existing Predefined Role not as Predefined. The role is still available under User Roles. +Existing User assignments to this role are unaffected. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Remove-TeamViewerPredefinedRole +``` + +Removes the Predefined Role tag from the Existing Predefined Role. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 + +## NOTES + +## RELATED LINKS diff --git a/Docs/Help/Set-TeamViewerPredefinedRole.md b/Docs/Help/Set-TeamViewerPredefinedRole.md new file mode 100644 index 0000000..377d320 --- /dev/null +++ b/Docs/Help/Set-TeamViewerPredefinedRole.md @@ -0,0 +1,88 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerPredefinedRole.md +schema: 2.0.0 +--- + +# Set-TeamViewerPredefinedRole + +## SYNOPSIS + +Add Predefined User Role. + +## SYNTAX + +```powershell +Set-TeamViewerPredefinedRole [-ApiToken] [-RoleId] [] +``` + +## DESCRIPTION + +Set an existing role as Predefined Role. It allows user creation with Predefined role assigned to the new user. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Set-TeamViewerPredefinedRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +``` + +Sets user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` as Predefined Role. + +### Example 1 + +```powershell +PS /> Get-TeamViewerUserRole | where-Object { ($_.RoleName -eq 'Test Role') } | Set-TeamViewerPredefinedRole +``` + +Sets user role with name `Test Role` as Predefined Role. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RoleId + +The user role to be set as Predefined Role. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: UserRole + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True +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 + +## NOTES + +## RELATED LINKS diff --git a/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 b/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 new file mode 100644 index 0000000..ae6a236 --- /dev/null +++ b/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerPredefinedRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod { + @{ PredefineduserRoleId = 'e1631449-6321-4a58-920c-5440029b092e' } + } +} + + +Describe 'Get-TeamViewerPredefinedRole' { + + It 'Should call the correct API endpoint to list PredefinedRole' { + Get-TeamViewerPredefinedRole -ApiToken $testApiToken + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq '//unit.test/userroles/predefined' -And ` + $Method -eq 'Get' } + } + + It 'Should convert input object to TeamViewerPS.PrefinedRole' { + $inputObject = @{ + PredefineduserRoleId = 'a9c9435d-8544-4e6a-9830-9337078c9aab' + } | ConvertTo-Json + + $result = $inputObject | ConvertFrom-Json | ConvertTo-TeamViewerPredefinedRole + + $result | Should -BeOfType [PSCustomObject] + $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.PredefinedRole' + $result.PredefinedRoleID | Should -Be 'a9c9435d-8544-4e6a-9830-9337078c9aab' + } + + + It 'Should return PredefinedRole objects' { + $result = Get-TeamViewerPredefinedRole -ApiToken $testApiToken + $result | Should -HaveCount 1 + $result[0].PSObject.TypeNames | Should -Contain 'TeamViewerPS.PredefinedRole' + } +} diff --git a/Tests/Public/Remove-TeamViewerPredefinedRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerPredefinedRole.Tests.ps1 new file mode 100644 index 0000000..c5c0b16 --- /dev/null +++ b/Tests/Public/Remove-TeamViewerPredefinedRole.Tests.ps1 @@ -0,0 +1,24 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerPredefinedRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod +} + + +Describe 'Remove-TeamViewerPredefinedRole' { + It 'Should call the correct API endpoint to remove PredefinedRole' { + Remove-TeamViewerPredefinedRole -ApiToken $testApiToken + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/userroles/predefined" -And ` + $Method -eq 'Delete' } + } +} diff --git a/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 b/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 new file mode 100644 index 0000000..dc9ecec --- /dev/null +++ b/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 @@ -0,0 +1,27 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerPredefinedRole.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testUserRoleId + + Mock Get-TeamViewerApiUri { '//unit.test' } + Mock Invoke-TeamViewerRestMethod +} + +Describe 'Set-TeamViewerPredefinedRole' { + It 'Should call the correct API endpoint' { + Set-TeamViewerPredefinedRole -ApiToken $testApiToken -RoleId $testUserRoleId + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/userroles/$testUserRoleId/predefined" -And ` + $Method -eq 'Put' + } + } + +} + From 311f578ded16cd0a4e0528aa7448ce1e1d759bf2 Mon Sep 17 00:00:00 2001 From: Karthick Gandhi Date: Fri, 20 Oct 2023 14:21:35 +0200 Subject: [PATCH 087/110] TeamViewerPS.psd1 update after build --- Cmdlets/TeamViewerPS.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 286d965..6b7e985 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerPredefinedRole','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPredefinedRole','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Resolve-TeamViewerUserRoleId','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPredefinedRole','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerRoleToAccount','Add-TeamViewerRoleToUserGroup','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerPredefinedRole','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPredefinedRole','Remove-TeamViewerPSProxy','Remove-TeamViewerRoleFromAccount','Remove-TeamViewerRoleFromUserGroup','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPredefinedRole','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() From fe22af7cd575d6bba9e4fc069bedc72ca20917ec Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Fri, 20 Oct 2023 19:12:58 +0200 Subject: [PATCH 088/110] Harmonize cmdlet names --- CHANGELOG.md | 2 +- .../ConvertTo-TeamViewerPredefinedRole.ps1 | 2 +- ...rRole.ps1 => ConvertTo-TeamViewerRole.ps1} | 4 +-- Cmdlets/Private/Resolve-TeamViewerRoleId.ps1 | 19 +++++++++++++ .../Private/Resolve-TeamViewerUserRoleId.ps1 | 19 ------------- ....ps1 => Add-TeamViewerUserGroupToRole.ps1} | 6 ++-- ...rRole.ps1 => Add-TeamViewerUserToRole.ps1} | 8 +++--- ...werUserRole.ps1 => Get-TeamViewerRole.ps1} | 4 +-- ...count.ps1 => Get-TeamViewerUserByRole.ps1} | 8 +++--- ....ps1 => Get-TeamViewerUserGroupByRole.ps1} | 10 +++---- ...werUserRole.ps1 => New-TeamViewerRole.ps1} | 6 ++-- ...UserRole.ps1 => Remove-TeamViewerRole.ps1} | 10 +++---- ....ps1 => Remove-TeamViewerUserFromRole.ps1} | 8 +++--- ...=> Remove-TeamViewerUserGroupFromRole.ps1} | 2 +- .../Public/Set-TeamViewerPredefinedRole.ps1 | 4 +-- ...werUserRole.ps1 => Set-TeamViewerRole.ps1} | 10 +++---- Cmdlets/TeamViewerPS.psd1 | 2 +- .../Help/Add-TeamViewerUserGroupToUserRole.md | 18 ++++++------ ...serRole.md => Add-TeamViewerUserToRole.md} | 16 +++++------ Docs/Help/Get-TeamViewerPredefinedRole.md | 2 +- ...Account.md => Get-TeamViewerUserByRole.md} | 14 +++++----- ...up.md => Get-TeamViewerUserGroupByRole.md} | 12 ++++---- Docs/Help/Get-TeamViewerUserRole.md | 16 +++++------ Docs/Help/New-TeamViewerUserRole.md | 22 +++++++-------- Docs/Help/Remove-TeamViewerPredefinedRole.md | 8 +++--- ...le.md => Remove-TeamViewerUserFromRole.md} | 22 +++++++-------- ... => Remove-TeamViewerUserGroupFromRole.md} | 16 +++++------ Docs/Help/Remove-TeamViewerUserRole.md | 24 ++++++++-------- Docs/Help/Set-TeamViewerPredefinedRole.md | 13 +++++---- Docs/Help/Set-TeamViewerUserRole.md | 12 ++++---- Docs/TeamViewerPS.md | 28 +++++++++---------- README.md | 2 +- ...> Add-TeamViewerUserGroupToRole.Tests.ps1} | 6 ++-- ...ps1 => Add-TeamViewerUserToRole.Tests.ps1} | 10 +++---- .../Get-TeamViewerPredefinedRole.Tests.ps1 | 4 +-- ...Tests.ps1 => Get-TeamViewerRole.Tests.ps1} | 18 ++++++------ ...eamViewerRoleAssignmentToAccount.Tests.ps1 | 11 ++++---- ...mViewerRoleAssignmentToUserGroup.Tests.ps1 | 10 +++---- ...tests.ps1 => New-TeamViewerRole.tests.ps1} | 14 +++++----- ...emove-TeamViewerAccountFromRole.Tests.ps1} | 10 +++---- ...ts.ps1 => Remove-TeamViewerRole.Tests.ps1} | 10 +++---- ...ove-TeamViewerUserGroupFromRole.Tests.ps1} | 8 +++--- ...Tests.ps1 => Set-TeamViewerRole.Tests.ps1} | 14 +++++----- 43 files changed, 232 insertions(+), 232 deletions(-) rename Cmdlets/Private/{ConvertTo-TeamViewerUserRole.ps1 => ConvertTo-TeamViewerRole.ps1} (86%) create mode 100644 Cmdlets/Private/Resolve-TeamViewerRoleId.ps1 delete mode 100644 Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 rename Cmdlets/Public/{Add-TeamViewerUserGroupToUserRole.ps1 => Add-TeamViewerUserGroupToRole.ps1} (87%) rename Cmdlets/Public/{Add-TeamViewerAccountToUserRole.ps1 => Add-TeamViewerUserToRole.ps1} (90%) rename Cmdlets/Public/{Get-TeamViewerUserRole.ps1 => Get-TeamViewerRole.ps1} (82%) rename Cmdlets/Public/{Get-TeamViewerRoleAssignmentToAccount.ps1 => Get-TeamViewerUserByRole.ps1} (82%) rename Cmdlets/Public/{Get-TeamViewerRoleAssignmentToUserGroup.ps1 => Get-TeamViewerUserGroupByRole.ps1} (77%) rename Cmdlets/Public/{New-TeamViewerUserRole.ps1 => New-TeamViewerRole.ps1} (86%) rename Cmdlets/Public/{Remove-TeamViewerUserRole.ps1 => Remove-TeamViewerRole.ps1} (73%) rename Cmdlets/Public/{Remove-TeamViewerAccountFromUserRole.ps1 => Remove-TeamViewerUserFromRole.ps1} (90%) rename Cmdlets/Public/{Remove-TeamViewerUserGroupFromUserRole.ps1 => Remove-TeamViewerUserGroupFromRole.ps1} (95%) rename Cmdlets/Public/{Set-TeamViewerUserRole.ps1 => Set-TeamViewerRole.ps1} (84%) rename Docs/Help/{Add-TeamViewerAccountToUserRole.md => Add-TeamViewerUserToRole.md} (77%) rename Docs/Help/{Get-TeamViewerRoleAssignmentToAccount.md => Get-TeamViewerUserByRole.md} (69%) rename Docs/Help/{Get-TeamViewerRoleAssignmentToUserGroup.md => Get-TeamViewerUserGroupByRole.md} (71%) rename Docs/Help/{Remove-TeamViewerAccountFromUserRole.md => Remove-TeamViewerUserFromRole.md} (69%) rename Docs/Help/{Remove-TeamViewerUserGroupFromUserRole.md => Remove-TeamViewerUserGroupFromRole.md} (75%) rename Tests/Public/{Add-TeamViewerUserGroupToUserRole.Tests.ps1 => Add-TeamViewerUserGroupToRole.Tests.ps1} (85%) rename Tests/Public/{Add-TeamViewerAccountToUserRole.Tests.ps1 => Add-TeamViewerUserToRole.Tests.ps1} (84%) rename Tests/Public/{Get-TeamViewerUserRole.Tests.ps1 => Get-TeamViewerRole.Tests.ps1} (84%) rename Tests/Public/{New-TeamViewerUserRole.tests.ps1 => New-TeamViewerRole.tests.ps1} (78%) rename Tests/Public/{Remove-TeamViewerAccountFromUserRole.Tests.ps1 => Remove-TeamViewerAccountFromRole.Tests.ps1} (83%) rename Tests/Public/{Remove-TeamViewerUserRole.Tests.ps1 => Remove-TeamViewerRole.Tests.ps1} (76%) rename Tests/Public/{Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 => Remove-TeamViewerUserGroupFromRole.Tests.ps1} (84%) rename Tests/Public/{Set-TeamViewerUserRole.Tests.ps1 => Set-TeamViewerRole.Tests.ps1} (80%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a20a6f..1eef9c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Adds commands to manage the user roles of a TeamViewer company. +- Adds commands to manage the roles of a TeamViewer company. - Adds `Set-TeamViewerApiURi` to use TeamViewer test API. - Adds `Add-TeamViewerAssignment` and `Remove-TeamViewerAssignment` commands to assign and unassign a device from a TeamViewer company. - Adds `Add-TeamViewerCustomization` and `Remove-TeamViewerCustomization` commands to apply and remove customization. diff --git a/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 index f03befa..1328533 100644 --- a/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 +++ b/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 @@ -7,7 +7,7 @@ function ConvertTo-TeamViewerPredefinedRole { process { if($InputObject){ $properties = @{ - PredefinedRoleId = $InputObject.PredefineduserRoleId + PredefinedRoleId = $InputObject.PredefinedRoleId } } diff --git a/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerRole.ps1 similarity index 86% rename from Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 rename to Cmdlets/Private/ConvertTo-TeamViewerRole.ps1 index 3ecf278..9e36ef4 100644 --- a/Cmdlets/Private/ConvertTo-TeamViewerUserRole.ps1 +++ b/Cmdlets/Private/ConvertTo-TeamViewerRole.ps1 @@ -1,4 +1,4 @@ -function ConvertTo-TeamViewerUserRole { +function ConvertTo-TeamViewerRole { param( [Parameter(ValueFromPipeline)] [PSObject] @@ -15,7 +15,7 @@ function ConvertTo-TeamViewerUserRole { } } $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserRole') + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Role') $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { Write-Output "[$($this.RoleName)] [$($this.RoleID)] $($this.Permissions))" } diff --git a/Cmdlets/Private/Resolve-TeamViewerRoleId.ps1 b/Cmdlets/Private/Resolve-TeamViewerRoleId.ps1 new file mode 100644 index 0000000..2fe622b --- /dev/null +++ b/Cmdlets/Private/Resolve-TeamViewerRoleId.ps1 @@ -0,0 +1,19 @@ + +function Resolve-TeamViewerRoleId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [Object] + $Role + ) + Process { + if ($Role.PSObject.TypeNames -contains 'TeamViewerPS.Role') { + return [string]$Role.RoleID + } + elseif ($Role -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { + return [string]$Role + } + else { + throw "Invalid role identifier '$Role'. Must be either a [TeamViewerPS.Role] or [UUID] " + } + } +} diff --git a/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 b/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 deleted file mode 100644 index 09b268e..0000000 --- a/Cmdlets/Private/Resolve-TeamViewerUserRoleId.ps1 +++ /dev/null @@ -1,19 +0,0 @@ - -function Resolve-TeamViewerUserRoleId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [Object] - $UserRole - ) - Process { - if ($UserRole.PSObject.TypeNames -contains 'TeamViewerPS.UserRole') { - return [string]$UserRole.RoleID - } - elseif ($UserRole -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { - return [string]$UserRole - } - else { - throw "Invalid role group identifier '$UserRole'. Must be either a [TeamViewerPS.UserRole] or [UUID] " - } - } -} diff --git a/Cmdlets/Public/Add-TeamViewerUserGroupToUserRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 similarity index 87% rename from Cmdlets/Public/Add-TeamViewerUserGroupToUserRole.ps1 rename to Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 index 9100816..17c4fdf 100644 --- a/Cmdlets/Public/Add-TeamViewerUserGroupToUserRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 @@ -1,4 +1,4 @@ -function Add-TeamViewerUserGroupToUserRole { +function Add-TeamViewerUserGroupToRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] @@ -6,7 +6,7 @@ function Add-TeamViewerUserGroupToUserRole { $ApiToken, [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('UserRoleId')] [object] $UserRole, @@ -20,7 +20,7 @@ function Add-TeamViewerUserGroupToUserRole { ) Begin { - $RoleId = $UserRole | Resolve-TeamViewerUserRoleId + $RoleId = $UserRole | Resolve-TeamViewerRoleId $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ diff --git a/Cmdlets/Public/Add-TeamViewerAccountToUserRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 similarity index 90% rename from Cmdlets/Public/Add-TeamViewerAccountToUserRole.ps1 rename to Cmdlets/Public/Add-TeamViewerUserToRole.ps1 index 1edea85..55b5f1c 100644 --- a/Cmdlets/Public/Add-TeamViewerAccountToUserRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 @@ -1,4 +1,4 @@ -function Add-TeamViewerAccountToUserRole { +function Add-TeamViewerUserToRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] @@ -6,10 +6,10 @@ function Add-TeamViewerAccountToUserRole { $ApiToken, [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('UserRole')] [object] - $UserRoleId, + $RoleId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [Alias('Id', 'UserIds')] @@ -18,7 +18,7 @@ function Add-TeamViewerAccountToUserRole { ) Begin { - $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $id = D | Resolve-TeamViewerRoleId $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" $AccountsToAdd = @() diff --git a/Cmdlets/Public/Get-TeamViewerUserRole.ps1 b/Cmdlets/Public/Get-TeamViewerRole.ps1 similarity index 82% rename from Cmdlets/Public/Get-TeamViewerUserRole.ps1 rename to Cmdlets/Public/Get-TeamViewerRole.ps1 index 3de2ecb..4623e83 100644 --- a/Cmdlets/Public/Get-TeamViewerUserRole.ps1 +++ b/Cmdlets/Public/Get-TeamViewerRole.ps1 @@ -1,4 +1,4 @@ -function Get-TeamViewerUserRole { +function Get-TeamViewerRole { [CmdletBinding(DefaultParameterSetName = '')] param( [Parameter(Mandatory = $true)] @@ -19,6 +19,6 @@ Process{ -Body $parameters ` -WriteErrorTo $PSCmdlet ` -ErrorAction Stop - Write-Output ($response.Roles | ConvertTo-TeamViewerUserRole ) + Write-Output ($response.Roles | ConvertTo-TeamViewerRole ) } } diff --git a/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 b/Cmdlets/Public/Get-TeamViewerUserByRole.ps1 similarity index 82% rename from Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 rename to Cmdlets/Public/Get-TeamViewerUserByRole.ps1 index ed89a07..e7d9175 100644 --- a/Cmdlets/Public/Get-TeamViewerRoleAssignmentToAccount.ps1 +++ b/Cmdlets/Public/Get-TeamViewerUserByRole.ps1 @@ -1,18 +1,18 @@ -function Get-TeamViewerRoleAssignmentToAccount { +function Get-TeamViewerUserByRole { param( [Parameter(Mandatory = $true)] [securestring] $ApiToken, [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('UserRole')] [string] - $UserRoleId + $RoleId ) - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$UserRoleId" + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$RoleId" $parameters = $null do { $response = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 b/Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 similarity index 77% rename from Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 rename to Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 index 3b369c2..d8cb9b4 100644 --- a/Cmdlets/Public/Get-TeamViewerRoleAssignmentToUserGroup.ps1 +++ b/Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 @@ -1,18 +1,18 @@ -function Get-TeamViewerRoleAssignmentToUserGroup { +function Get-TeamViewerUserGroupByRole { param( [Parameter(Mandatory = $true)] [securestring] $ApiToken, [Parameter(Mandatory = $true)] - [ValidateScript({ $_ | Resolve-TeamviewerUserRoleId })] + [ValidateScript({ $_ | Resolve-TeamViewerRoleId })] [Alias('UserRole')] [string] - $UserRoleId + $RoleId ) Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$UserRoleId" + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$RoleId" $parameters = $null } Process { @@ -25,7 +25,7 @@ function Get-TeamViewerRoleAssignmentToUserGroup { -WriteErrorTo $PSCmdlet ` -ErrorAction Stop if ($response.ContinuationToken) { - $resourceUri += "&continuationToken=" + $response.ContinuationToken + $resourceUri += '&continuationToken=' + $response.ContinuationToken } Write-Output ($response.AssignedToGroups | ConvertTo-TeamViewerRoleAssignedUserGroup ) }while ($response.ContinuationToken) diff --git a/Cmdlets/Public/New-TeamViewerUserRole.ps1 b/Cmdlets/Public/New-TeamViewerRole.ps1 similarity index 86% rename from Cmdlets/Public/New-TeamViewerUserRole.ps1 rename to Cmdlets/Public/New-TeamViewerRole.ps1 index 27a93b3..487896b 100644 --- a/Cmdlets/Public/New-TeamViewerUserRole.ps1 +++ b/Cmdlets/Public/New-TeamViewerRole.ps1 @@ -1,5 +1,5 @@ -function New-TeamViewerUserRole { +function New-TeamViewerRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true )] @@ -29,7 +29,7 @@ function New-TeamViewerUserRole { } Process { - if ($PSCmdlet.ShouldProcess($Name, 'Create User Role')) { + if ($PSCmdlet.ShouldProcess($Name, 'Create Role')) { $response = Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` @@ -39,7 +39,7 @@ function New-TeamViewerUserRole { -WriteErrorTo $PSCmdlet ` -ErrorAction Stop - $result = ($response.Role | ConvertTo-TeamViewerUserRole) + $result = ($response.Role | ConvertTo-TeamViewerRole) Write-Output $result } } diff --git a/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 b/Cmdlets/Public/Remove-TeamViewerRole.ps1 similarity index 73% rename from Cmdlets/Public/Remove-TeamViewerUserRole.ps1 rename to Cmdlets/Public/Remove-TeamViewerRole.ps1 index e83577e..df5e7f7 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerUserRole { +function Remove-TeamViewerRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] @@ -6,19 +6,19 @@ function Remove-TeamViewerUserRole { $ApiToken, [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('UserRole')] [Alias('Id')] [object] - $UserRoleId + $RoleId ) Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$UserRoleId" + $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$RoleId" } Process { - if ($PSCmdlet.ShouldProcess($UserRoleId.ToString(), 'Remove User Role')) { + if ($PSCmdlet.ShouldProcess($RoleId.ToString(), 'Remove Role')) { Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` diff --git a/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 similarity index 90% rename from Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 index 99455b5..4861e96 100644 --- a/Cmdlets/Public/Remove-TeamViewerAccountFromUserRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerAccountFromUserRole { +function Remove-TeamViewerUserFromRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] @@ -6,10 +6,10 @@ function Remove-TeamViewerAccountFromUserRole { $ApiToken, [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('UserRole')] [object] - $UserRoleId, + $RoleId, [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [Alias('Id', 'UserIds')] @@ -18,7 +18,7 @@ function Remove-TeamViewerAccountFromUserRole { ) Begin { - $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $id = $RoleId | Resolve-TeamViewerRoleId $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" $AccountsToRemove = @() diff --git a/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 similarity index 95% rename from Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 rename to Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 index 1512fe2..c07000f 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserGroupFromUserRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserGroupFromRole.ps1 @@ -1,4 +1,4 @@ -function Remove-TeamViewerUserGroupFromUserRole { +function Remove-TeamViewerUserGroupFromRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] diff --git a/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 b/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 index 88376a5..9247166 100644 --- a/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 +++ b/Cmdlets/Public/Set-TeamViewerPredefinedRole.ps1 @@ -6,13 +6,13 @@ function Set-TeamViewerPredefinedRole { $ApiToken, [Parameter(Mandatory = $true, ValueFromPipeline = $true )] - [ValidateScript({ $_ | Resolve-TeamViewerUserRoleId })] + [ValidateScript({ $_ | Resolve-TeamViewerRoleId })] [object] $RoleId ) Process { - $Role = $RoleId | Resolve-TeamViewerUserRoleId + $Role = $RoleId | Resolve-TeamViewerRoleId $resourceUri = "$(Get-TeamViewerApiUri)/userroles/$Role/predefined" if ($PSCmdlet.ShouldProcess($Role, 'Set Predefined Role')) { Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/Cmdlets/Public/Set-TeamViewerRole.ps1 similarity index 84% rename from Cmdlets/Public/Set-TeamViewerUserRole.ps1 rename to Cmdlets/Public/Set-TeamViewerRole.ps1 index d8dbae1..c495441 100644 --- a/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/Cmdlets/Public/Set-TeamViewerRole.ps1 @@ -1,5 +1,5 @@ -function Set-TeamViewerUserRole { +function Set-TeamViewerRole { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true )] @@ -17,17 +17,17 @@ function Set-TeamViewerUserRole { $Permissions, [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('UserRole')] [object] - $UserRoleId + $RoleId ) Begin { $resourceUri = "$(Get-TeamViewerApiUri)/userroles" $body = @{ Name = $Name Permissions = @() - UserRoleId = $UserRoleId + UserRoleId = $RoleId } if ($Permissions) { @@ -35,7 +35,7 @@ function Set-TeamViewerUserRole { } } Process { - if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { + if ($PSCmdlet.ShouldProcess($Name, 'Update Role')) { $response = Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index a95f3c0..70615f4 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,7 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment','Add-TeamViewerCustomization','Add-TeamViewerManagedDevice','Add-TeamViewerManager','Add-TeamViewerAccountToUserRole','Add-TeamViewerUserGroupToUserRole','Add-TeamViewerSsoExclusion','Add-TeamViewerUserGroupMember','Connect-TeamViewerApi','Disconnect-TeamViewerApi','Export-TeamViewerSystemInformation','Get-TeamViewerAccount','Get-TeamViewerConnectionReport','Get-TeamViewerContact','Get-TeamViewerCustomModuleId','Get-TeamViewerDevice','Get-TeamViewerEventLog','Get-TeamViewerGroup','Get-TeamViewerId','Get-TeamViewerInstallationDirectory','Get-TeamViewerLogFilePath','Get-TeamViewerManagedDevice','Get-TeamViewerManagedGroup','Get-TeamViewerManagementId','Get-TeamViewerManager','Get-TeamViewerPolicy','Get-TeamViewerPredefinedRole','Get-TeamViewerRoleAssignmentToAccount','Get-TeamViewerRoleAssignmentToUserGroup','Get-TeamViewerService','Get-TeamViewerSsoDomain','Get-TeamViewerSsoExclusion','Get-TeamViewerUser','Get-TeamViewerUserGroup','Get-TeamViewerUserGroupMember','Get-TeamViewerUserRole','Get-TeamViewerVersion','Invoke-TeamViewerPackageDownload','Invoke-TeamViewerPing','New-TeamViewerContact','New-TeamViewerDevice','New-TeamViewerGroup','New-TeamViewerManagedGroup','New-TeamViewerPolicy','New-TeamViewerUser','New-TeamViewerUserGroup','New-TeamViewerUserRole','Publish-TeamViewerGroup','Remove-TeamViewerAssignment','Remove-TeamViewerContact','Remove-TeamViewerCustomization','Remove-TeamViewerDevice','Remove-TeamViewerGroup','Remove-TeamViewerManagedDevice','Remove-TeamViewerManagedDeviceManagement','Remove-TeamViewerManagedGroup','Remove-TeamViewerManager','Remove-TeamViewerPolicy','Remove-TeamViewerPolicyFromManagedDevice','Remove-TeamViewerPredefinedRole','Remove-TeamViewerPSProxy','Remove-TeamViewerAccountFromUserRole','Remove-TeamViewerUserGroupFromUserRole','Remove-TeamViewerSsoExclusion','Remove-TeamViewerUser','Remove-TeamViewerUserGroup','Remove-TeamViewerUserGroupMember','Remove-TeamViewerUserRole','Restart-TeamViewerService','Set-TeamViewerAccount','Set-TeamViewerAPIUri','Set-TeamViewerDevice','Set-TeamViewerGroup','Set-TeamViewerManagedDevice','Set-TeamViewerManagedGroup','Set-TeamViewerManager','Set-TeamViewerPolicy','Set-TeamViewerPredefinedRole','Set-TeamViewerPSProxy','Set-TeamViewerUser','Set-TeamViewerUserGroup','Set-TeamViewerUserRole','Start-TeamViewerService','Stop-TeamViewerService','Test-TeamViewerConnectivity','Test-TeamViewerInstallation','Unpublish-TeamViewerGroup') + FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerUserToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerPredefinedRole', 'Get-TeamViewerUserByRole', 'Get-TeamViewerUserGroupByRole', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPredefinedRole', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerUserFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPredefinedRole', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') # Cmdlets to export from this module. CmdletsToExport = @() diff --git a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md index edd1472..4bbad69 100644 --- a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md +++ b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md @@ -1,36 +1,36 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserGroupToUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserGroupToRole.md schema: 2.0.0 --- -# Add-TeamViewerUserGroupToUserRole +# Add-TeamViewerUserGroupToRole ## SYNOPSIS -Assign user role to a user group. +Assign a user group to a role. ## SYNTAX ```powershell -Add-TeamViewerUserGroupToUserRole [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] +Add-TeamViewerUserGroupToRole [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Assigns user role to a user group of the TeamViewer company associated with the API access token. +Assigns a user group to a role of the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Add-TeamViewerUserGroupToUserRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 +PS /> Add-TeamViewerUserGroupToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 ``` -The given user group `1001` gets assigned to the user role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. +The given user group `1001` gets assigned to the role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. ## PARAMETERS @@ -68,7 +68,7 @@ Accept wildcard characters: False ### -UserRole -The user role to be assigned to the accountIds +The role to be assigned to the accountIds ```yaml Type: Object @@ -84,7 +84,7 @@ Accept wildcard characters: False ### -UserGroup -The user group to which the user role should be assigned. +The user group to which the role should be assigned. ```yaml Type: Object diff --git a/Docs/Help/Add-TeamViewerAccountToUserRole.md b/Docs/Help/Add-TeamViewerUserToRole.md similarity index 77% rename from Docs/Help/Add-TeamViewerAccountToUserRole.md rename to Docs/Help/Add-TeamViewerUserToRole.md index b90b954..8bc5c46 100644 --- a/Docs/Help/Add-TeamViewerAccountToUserRole.md +++ b/Docs/Help/Add-TeamViewerUserToRole.md @@ -1,33 +1,33 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerAccountToUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerUserToRole.md schema: 2.0.0 --- -# Add-TeamViewerAccountToUserRole +# Add-TeamViewerUserToRole ## SYNOPSIS -Assign user role to a list of accountIds. +Assign a list of accountIds to a role. ## SYNTAX ```powershell -Add-TeamViewerAccountToUserRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] +Add-TeamViewerUserToRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Assigns user role to one or many users. User role should belong to the TeamViewer company associated with the API access token. +Assigns one or many users to a role. A role should belong to the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Add-TeamViewerAccountToUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Add-TeamViewerUserToRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. @@ -35,7 +35,7 @@ Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `12 ### Example 2 ```powershell -PS /> @('123', '456', '789') | Add-TeamViewerAccountToUserRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Add-TeamViewerUserToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. @@ -77,7 +77,7 @@ Accept wildcard characters: False ### -UserRoleId -the user role to which users will be assigned to. +the role to which users will be assigned to. ```yaml Type: Object diff --git a/Docs/Help/Get-TeamViewerPredefinedRole.md b/Docs/Help/Get-TeamViewerPredefinedRole.md index 14478c9..57c00ea 100644 --- a/Docs/Help/Get-TeamViewerPredefinedRole.md +++ b/Docs/Help/Get-TeamViewerPredefinedRole.md @@ -34,7 +34,7 @@ Retrieves the Predefined Role ID. ### Example 2 ```powershell -PS /> forEach-Object { Get-TeamViewerUserRole | Where-Object { $_.RoleID -eq (Get-TeamViewerPredefinedRole).PredefinedRoleID } } +PS /> forEach-Object { Get-TeamViewerRole | Where-Object { $_.RoleID -eq (Get-TeamViewerPredefinedRole).PredefinedRoleID } } ``` Retrieves the complete information about the predefined role. diff --git a/Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md b/Docs/Help/Get-TeamViewerUserByRole.md similarity index 69% rename from Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md rename to Docs/Help/Get-TeamViewerUserByRole.md index cc9b3bc..80136ee 100644 --- a/Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md +++ b/Docs/Help/Get-TeamViewerUserByRole.md @@ -1,35 +1,35 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerRoleAssignmentToAccount.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerUserByRole.md schema: 2.0.0 --- -# Get-TeamViewerRoleAssignmentToAccount +# Get-TeamViewerUserByRole ## SYNOPSIS -Lists all user role assignments of a user role. +Lists users assigned to one specific role. ## SYNTAX ```powershell -Get-TeamViewerRoleAssignmentToAccount [-ApiToken] [-UserRoleId] [] +Get-TeamViewerUserByRole [-ApiToken] [-UserRoleId] [] ``` ## DESCRIPTION -Lists all user role assignments of user role in the TeamViewer company associated with the API access token. +Lists all users of role in the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Get-TeamViewerRoleAssignmentToAccount -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' +PS /> Get-TeamViewerUserByRole -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' ``` -Lists all user assignments of user role `72abbedc-9853-4fc8-9d28-fa35e207b048`. +Lists all users of the ole `72abbedc-9853-4fc8-9d28-fa35e207b048`. ## PARAMETERS diff --git a/Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md b/Docs/Help/Get-TeamViewerUserGroupByRole.md similarity index 71% rename from Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md rename to Docs/Help/Get-TeamViewerUserGroupByRole.md index d96ae56..12ef9fb 100644 --- a/Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md +++ b/Docs/Help/Get-TeamViewerUserGroupByRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerRoleAssignmentToUserGroup.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerUserGroupByRole.md schema: 2.0.0 --- -# Get-TeamViewerRoleAssignmentToUserGroup +# Get-TeamViewerUserGroupByRole ## SYNOPSIS @@ -14,22 +14,22 @@ Lists all user group assignments of a user role. ## SYNTAX ```powershell -Get-TeamViewerRoleAssignmentToUserGroup [-ApiToken] [-UserRoleId] [] +Get-TeamViewerUserGroupByRole [-ApiToken] [-UserRoleId] [] ``` ## DESCRIPTION -Lists all user group assignments of a user role in the TeamViewer company associated with the API access token. +Lists all user groups of role in the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Get-TeamViewerRoleAssignmentToUserGroup -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' +PS /> Get-TeamViewerUserGroupByRole -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' ``` -Lists all user group assignments of user role `72abbedc-9853-4fc8-9d28-fa35e207b048`. +Lists all user groups of the role `72abbedc-9853-4fc8-9d28-fa35e207b048`. ## PARAMETERS diff --git a/Docs/Help/Get-TeamViewerUserRole.md b/Docs/Help/Get-TeamViewerUserRole.md index 036d199..b946d4b 100644 --- a/Docs/Help/Get-TeamViewerUserRole.md +++ b/Docs/Help/Get-TeamViewerUserRole.md @@ -1,35 +1,35 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerRole.md schema: 2.0.0 --- -# Get-TeamViewerUserRole +# Get-TeamViewerRole ## SYNOPSIS -Retrieve user roles in a TeamViewer company. +Lists all roles and their permissions in a TeamViewer company. ## SYNTAX ```powershell -Get-TeamViewerUserRole [-ApiToken] [] +Get-TeamViewerRole [-ApiToken] [] ``` ## DESCRIPTION -Lists all user roles in the TeamViewer company associated with the API access token. +Lists all roles in the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Get-TeamViewerUserRole +PS /> Get-TeamViewerRole ``` -List all user roles and their permissions. +Lists all roles and their permissions. ## PARAMETERS @@ -61,7 +61,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.Object -An array of `TeamViewerPS.UserRole` objects. +An array of `TeamViewerPS.Role` objects. ## NOTES diff --git a/Docs/Help/New-TeamViewerUserRole.md b/Docs/Help/New-TeamViewerUserRole.md index 6f482c2..a991b94 100644 --- a/Docs/Help/New-TeamViewerUserRole.md +++ b/Docs/Help/New-TeamViewerUserRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/New-TeamViewerRole.md schema: 2.0.0 --- -# New-TeamViewerUserRole +# New-TeamViewerRole ## SYNOPSIS @@ -14,33 +14,33 @@ Create a new user role. ## SYNTAX ``` powershell -New-TeamViewerUserRole [-ApiToken] [-Name] [-Permissions] [-WhatIf] [-Confirm] [] +New-TeamViewerRole [-ApiToken] [-Name] [-Permissions] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Create a new user role that belongs to the TeamViewer company associated with the API access token. -The name of the new user role should be unique among the user roles of the TeamViewer Company. +Create a new role that belongs to the TeamViewer company associated with the API access token. +The name of the new role should be unique among the roles of the TeamViewer Company. ## EXAMPLES ### Example 1 ```powershell -PS /> New-TeamViewerUserRole -Name 'New user role' -Permissions 'AllowGroupharing','ManageConnections' +PS /> New-TeamViewerRole -Name 'New role' -Permissions 'AllowGroupharing','ManageConnections' ``` -Creates a new user role with name `New user role` with permissions `AllowGroupSharing` and `ManageConnections` enabled. +Creates a new role with name `New role` with permissions `AllowGroupSharing` and `ManageConnections` enabled. Please see the TeamViewer API documentation for a list of valid values. ### Example 2 ```powershell -PS /> New-TeamViewerUserRole -Name 'New user role' +PS /> New-TeamViewerRole -Name 'New role' ``` -Creates a new user role with name `New user role` without any permissions. -The name should be unique among the user roles of the TeamViewer Company. +Creates a new role with name `New role` without any permissions. +The name should be unique among the roles of the TeamViewer Company. ## PARAMETERS @@ -137,7 +137,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.Object -A `TeamViewerPS.UserRole` object. +A `TeamViewerPS.Role` object. ## NOTES diff --git a/Docs/Help/Remove-TeamViewerPredefinedRole.md b/Docs/Help/Remove-TeamViewerPredefinedRole.md index 69bfeea..5ed3d86 100644 --- a/Docs/Help/Remove-TeamViewerPredefinedRole.md +++ b/Docs/Help/Remove-TeamViewerPredefinedRole.md @@ -9,7 +9,7 @@ schema: 2.0.0 ## SYNOPSIS -Remove existing Predefined Role. +Remove existing predefined role. ## SYNTAX @@ -20,8 +20,8 @@ Remove-TeamViewerPredefinedRole [-ApiToken] [-UserRoleId] Remove-TeamViewerPredefinedRole ``` -Removes the Predefined Role tag from the Existing Predefined Role. +Removes the predefined role flag from the role. ## PARAMETERS diff --git a/Docs/Help/Remove-TeamViewerAccountFromUserRole.md b/Docs/Help/Remove-TeamViewerUserFromRole.md similarity index 69% rename from Docs/Help/Remove-TeamViewerAccountFromUserRole.md rename to Docs/Help/Remove-TeamViewerUserFromRole.md index 7af8438..3066182 100644 --- a/Docs/Help/Remove-TeamViewerAccountFromUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserFromRole.md @@ -1,53 +1,53 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerAccountFromUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserFromRole.md schema: 2.0.0 --- -# Remove-TeamViewerAccountFromUserRole +# Remove-TeamViewerUserFromRole ## SYNOPSIS -Unassign a given list of accounts from user role. +Un-assigns one or many users from a role. ## SYNTAX ### ByUserRoleIdMemberId (All) ```powershell -Remove-TeamViewerAccountFromUserRole [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerUserFromRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ### ByUserId ```powershell -Remove-TeamViewerAccountFromUserRole [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerUserFromRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Unassigns one or many users from user role. User role should belong to the TeamViewer company associated with the API access token. +Un-assigns one or many users from a role. A role belongs to the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Remove-TeamViewerAccountFromUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Remove-TeamViewerUserFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` -Unassigns users with id `123`, `456`, `789` from user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. +Un-assigns users with id `123`, `456`, `789` from the role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. ### Example 2 ```powershell -PS /> @('123', '456', '789') | Remove-TeamViewerAccountFromUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Remove-TeamViewerUserFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` -Unassigns users with id `123`, `456`, `789` from user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. +Un-assigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. Ids are passed as pipeline input. ## PARAMETERS @@ -86,7 +86,7 @@ Accept wildcard characters: False ### -UserRoleId -The user role where users will be unassigned from. +The role where users will be unassigned from. ```yaml Type: Object diff --git a/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md b/Docs/Help/Remove-TeamViewerUserGroupFromRole.md similarity index 75% rename from Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md rename to Docs/Help/Remove-TeamViewerUserGroupFromRole.md index 585ed91..3f90817 100644 --- a/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserGroupFromRole.md @@ -1,36 +1,36 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroupFromUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserGroupFromRole.md schema: 2.0.0 --- -# Remove-TeamViewerUserGroupFromUserRole +# Remove-TeamViewerUserGroupFromRole ## SYNOPSIS -Unassign a user group from a user role. +Un-assigns a user group from one specific role. ## SYNTAX ```powershell -Remove-TeamViewerUserGroupFromUserRole [-ApiToken] [-UserGroup] [-WhatIf] +Remove-TeamViewerUserGroupFromRole [-ApiToken] [-UserGroup] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Unassigns user group from a user role of the TeamViewer company associated with the API access token. +Un-assigns a user group from one specific role of the TeamViewer company associated with the API access token. ## EXAMPLES ### Example 1 ```powershell -PS /> Remove-TeamViewerUserGroupFromUserRole -UserGroup 1001 +PS /> Remove-TeamViewerUserGroupFromRole -UserGroup 1001 ``` -The given user group `1001` gets unassigned from its user role. +The given user group `1001` gets unassigned from the role. ## PARAMETERS @@ -68,7 +68,7 @@ Accept wildcard characters: False ### -UserGroup -The user group from which user role should be unassigned. +The user group from which role should be unassigned. ```yaml Type: Object diff --git a/Docs/Help/Remove-TeamViewerUserRole.md b/Docs/Help/Remove-TeamViewerUserRole.md index ba83a1a..bf37f64 100644 --- a/Docs/Help/Remove-TeamViewerUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserRole.md @@ -1,46 +1,46 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerRole.md schema: 2.0.0 --- -# Remove-TeamViewerUserRole +# Remove-TeamViewerRole ## SYNOPSIS -Delete a user role from the TeamViewer company. +Deletes one specific role from the TeamViewer company. ## SYNTAX ```powershell -Remove-TeamViewerUserRole [-ApiToken] [-UserRoleId] [-WhatIf] [-Confirm] +Remove-TeamViewerRole [-ApiToken] [-UserRoleId] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION -Deletes a user role from the TeamViewer company. -All permissions and assignments of the user role will be deleted too. +Deletes one specific role from the TeamViewer company. +All permissions and user assignments of the role will be deleted too. ## EXAMPLES ### Example 1 ```powershell -PS /> Remove-TeamViewerUserRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> Remove-TeamViewerRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` -Deletes the user role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. +Deletes the role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. ### Example 2 ```powershell -PS /> Remove-TeamViewerUserRole -UserRoleId (Get-TeamViewerUserRole | Where-Object { ($_.RoleName -eq 'Test Role') } ).RoleID +PS /> Remove-TeamViewerRole -UserRoleId (Get-TeamViewerRole | Where-Object { ($_.RoleName -eq 'Test Role') } ).RoleID ``` -Removes a user role with RoleId retrieved using `Get-TeamViewerUserRole` as input. -In this example, the user role with the name `Test Role`. +Deletes a role with the role Id retrieved from `Get-TeamViewerRole` as input. +In this example, the role with the name `Test Role`. ## PARAMETERS @@ -78,7 +78,7 @@ Accept wildcard characters: False ### -UserRoleId -The user role to be deleted. +The role to be deleted. ```yaml Type: Object diff --git a/Docs/Help/Set-TeamViewerPredefinedRole.md b/Docs/Help/Set-TeamViewerPredefinedRole.md index 377d320..976147a 100644 --- a/Docs/Help/Set-TeamViewerPredefinedRole.md +++ b/Docs/Help/Set-TeamViewerPredefinedRole.md @@ -9,7 +9,7 @@ schema: 2.0.0 ## SYNOPSIS -Add Predefined User Role. +Sets an existing role as predefined role. ## SYNTAX @@ -19,7 +19,8 @@ Set-TeamViewerPredefinedRole [-ApiToken] [-RoleId] [ Set-TeamViewerPredefinedRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` -Sets user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` as Predefined Role. +Sets the role with the id `9b465ea2-2f75-4101-a057-58a81ed0e57b` as predefined role. ### Example 1 ```powershell -PS /> Get-TeamViewerUserRole | where-Object { ($_.RoleName -eq 'Test Role') } | Set-TeamViewerPredefinedRole +PS /> Get-TeamViewerRole | where-Object { ($_.RoleName -eq 'Test Role') } | Set-TeamViewerPredefinedRole ``` -Sets user role with name `Test Role` as Predefined Role. +Sets the role with name `Test Role` as predefined role. ## PARAMETERS @@ -59,7 +60,7 @@ Accept wildcard characters: False ### -RoleId -The user role to be set as Predefined Role. +The role to be set as Predefined Role. ```yaml Type: Object diff --git a/Docs/Help/Set-TeamViewerUserRole.md b/Docs/Help/Set-TeamViewerUserRole.md index d54e14c..2d2cb7b 100644 --- a/Docs/Help/Set-TeamViewerUserRole.md +++ b/Docs/Help/Set-TeamViewerUserRole.md @@ -1,11 +1,11 @@ --- external help file: TeamViewerPS-help.xml Module Name: TeamViewerPS -online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerUserRole.md +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerRole.md schema: 2.0.0 --- -# Set-TeamViewerUserRole +# Set-TeamViewerRole ## SYNOPSIS @@ -14,7 +14,7 @@ Update properties of a user role. ## SYNTAX ```powershell -Set-TeamViewerUserRole [-ApiToken] [-Name] [-UserRoleId] [-Permissions] [-WhatIf] [-Confirm] [] +Set-TeamViewerRole [-ApiToken] [-Name] [-UserRoleId] [-Permissions] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -26,10 +26,10 @@ Update properties of a user role. It allows to rename and alter permissions. ### Example 1 ```powershell -PS /> Set-TeamViewerUserRole -Name 'New name of user role' -Permissions 'AllowGroupSharing','ModifyConnections' -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> Set-TeamViewerRole -Name 'New name of role' -Permissions 'AllowGroupSharing','ModifyConnections' -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` -Renames a user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to `New name of user role` and enables the permissions `AllowGroupSharing` and `ModifyConnections`. +Renames the role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to `New name of role` and enables the permissions `AllowGroupSharing` and `ModifyConnections`. ## PARAMETERS @@ -67,7 +67,7 @@ Accept wildcard characters: False ### -UserRoleId -The user role to be updated. +The role to be updated. ```yaml Type: Object diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index d0d10aa..fe0e802 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -16,7 +16,7 @@ Assign or unassign a device to a company The following functions are available in this category: -[`Add-TeamViewerAssinment.md`](Help/Add-TeamViewerAssignment.md) +[`Add-TeamViewerAssignment.md`](Help/Add-TeamViewerAssignment.md) [`Remove-TeamViewerAssignment.md`](Help/Remove-TeamViewerAssignment.md) @@ -96,32 +96,32 @@ The following functions are available in this category: [`Remove-TeamViewerUserGroupMember`](Help/Remove-TeamViewerUserGroupMember.md) -## User Roles +## Roles -Remotely manage the user roles of a TeamViewer company via the -TeamViewer Web API. Have user roles to assign roles to company members. +Remotely manage the roles of a TeamViewer company via the +TeamViewer Web API. Have roles to assign permissions to company users. The following functions are available in this category: -[`Get-TeamViewerUserRole`](Help/Get-TeamViewerUserRole.md) +[`Get-TeamViewerRole`](Help/Get-TeamViewerRole.md) -[`New-TeamViewerUserRole`](Help/New-TeamViewerUserRole.md) +[`New-TeamViewerRole`](Help/New-TeamViewerRole.md) -[`Set-TeamViewerUserRole`](Help/Set-TeamViewerUserRole.md) +[`Set-TeamViewerRole`](Help/Set-TeamViewerRole.md) -[`Remove-TeamViewerUserRole`](Help/Remove-TeamViewerUserRole.md) +[`Remove-TeamViewerRole`](Help/Remove-TeamViewerRole.md) -[`Get-TeamViewerRoleAssignmentToAccount`](Help/Get-TeamViewerRoleAssignmentToAccount.md) +[`Get-TeamViewerUserByRole`](Help/Get-TeamViewerUserByRole.md) -[`Get-TeamViewerRoleAssignmentToUserGroup`](Help/Get-TeamViewerRoleAssignmentToUserGroup.md) +[`Get-TeamViewerUserGroupByRole`](Help/Get-TeamViewerUserGroupByRole.md) -[`Add-TeamViewerAccountToUserRole`](Help/Add-TeamViewerAccountToUserRole.md) +[`Add-TeamViewerUserToRole`](Help/Add-TeamViewerUserToRole.md) -[`Add-TeamViewerUserGroupToUserRole`](Help/Add-TeamViewerUserGroupToUserRole.md) +[`Add-TeamViewerUserGroupToRole`](Help/Add-TeamViewerUserGroupToRole.md) -[`Remove-TeamViewerAccountFromUserRole`](Help/Remove-TeamViewerAccountFromUserRole.md) +[`Remove-TeamViewerUserFromRole`](Help/Remove-TeamViewerUserFromRole.md) -[`Remove-TeamViewerUserGroupFromUserRole`](Help/Remove-TeamViewerUserGroupFromUserRole.md) +[`Remove-TeamViewerUserGroupFromRole`](Help/Remove-TeamViewerUserGroupFromRole.md) ## Managed Groups & Managed Devices diff --git a/README.md b/README.md index 3b4cdb6..58f35ce 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The module provides functions for the following categories: - _Computers & Contacts list_ - _User management_ - _User groups_ -- _User roles_ +- _Roles_ - _Managed groups_ - _Policy management_ - _Single Sign-On (SSO) management_ diff --git a/Tests/Public/Add-TeamViewerUserGroupToUserRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 similarity index 85% rename from Tests/Public/Add-TeamViewerUserGroupToUserRole.Tests.ps1 rename to Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 index a571247..ba0e965 100644 --- a/Tests/Public/Add-TeamViewerUserGroupToUserRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserGroupToUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserGroupToRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -18,9 +18,9 @@ BeforeAll { } } } -Describe 'Add-TeamViewerUserGroupToUserRole' { +Describe 'Add-TeamViewerUserGroupToRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerUserGroupToUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Add-TeamViewerUserGroupToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/Tests/Public/Add-TeamViewerAccountToUserRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 similarity index 84% rename from Tests/Public/Add-TeamViewerAccountToUserRole.Tests.ps1 rename to Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 index 6b76774..693bebf 100644 --- a/Tests/Public/Add-TeamViewerAccountToUserRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerAccountToUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerUserToRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -19,10 +19,10 @@ BeforeAll { } } } -Describe 'Add-TeamViewerAccountToUserRole' { +Describe 'Add-TeamViewerUserToRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerAccountToUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Add-TeamViewerUserToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -33,7 +33,7 @@ Describe 'Add-TeamViewerAccountToUserRole' { It 'Should assign the given account to the user role' { - Add-TeamViewerAccountToUserRole ` + Add-TeamViewerUserToRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId ` -Accounts $testAccount @@ -47,7 +47,7 @@ Describe 'Add-TeamViewerAccountToUserRole' { } It 'Should accept pipeline input' { - $testAccount | Add-TeamViewerAccountToUserRole ` + $testAccount | Add-TeamViewerUserToRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty diff --git a/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 b/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 index ae6a236..ac17da0 100644 --- a/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 @@ -9,7 +9,7 @@ BeforeAll { Mock Get-TeamViewerApiUri { '//unit.test' } Mock Invoke-TeamViewerRestMethod { - @{ PredefineduserRoleId = 'e1631449-6321-4a58-920c-5440029b092e' } + @{ PredefinedRoleId = 'e1631449-6321-4a58-920c-5440029b092e' } } } @@ -27,7 +27,7 @@ Describe 'Get-TeamViewerPredefinedRole' { It 'Should convert input object to TeamViewerPS.PrefinedRole' { $inputObject = @{ - PredefineduserRoleId = 'a9c9435d-8544-4e6a-9830-9337078c9aab' + PredefinedRoleId = 'a9c9435d-8544-4e6a-9830-9337078c9aab' } | ConvertTo-Json $result = $inputObject | ConvertFrom-Json | ConvertTo-TeamViewerPredefinedRole diff --git a/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Get-TeamViewerRole.Tests.ps1 similarity index 84% rename from Tests/Public/Get-TeamViewerUserRole.Tests.ps1 rename to Tests/Public/Get-TeamViewerRole.Tests.ps1 index 4dc84ce..5ba42b5 100644 --- a/Tests/Public/Get-TeamViewerUserRole.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRole.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -18,10 +18,10 @@ BeforeAll { } } -Describe 'Get-TeamViewerUserRole' { +Describe 'Get-TeamViewerRole' { It 'Should call the correct API endpoint to list roles' { - Get-TeamViewerUserRole -ApiToken $testApiToken + Get-TeamViewerRole -ApiToken $testApiToken Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -29,7 +29,7 @@ Describe 'Get-TeamViewerUserRole' { $Method -eq 'Get' } } - It 'Should convert input object to TeamViewerPS.UserRole' { + It 'Should convert input object to TeamViewerPS.Role' { $inputObject = @{ id = 'a9c9435d-8544-4e6a-9830-9337078c9aab' name = 'Role 1' @@ -41,10 +41,10 @@ Describe 'Get-TeamViewerUserRole' { } } | ConvertTo-Json - $result = $inputObject | ConvertFrom-Json | ConvertTo-TeamViewerUserRole + $result = $inputObject | ConvertFrom-Json | ConvertTo-TeamViewerRole $result | Should -BeOfType [PSCustomObject] - $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.UserRole' + $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.Role' $result.RoleName | Should -Be 'Role 1' $result.RoleID | Should -Be 'a9c9435d-8544-4e6a-9830-9337078c9aab' $result.AllowGroupSharing | Should -Be $true @@ -54,7 +54,7 @@ Describe 'Get-TeamViewerUserRole' { } It 'Should call the correct API endpoint for assigned users' { - Get-TeamViewerUserRole -ApiToken $testApiToken + Get-TeamViewerRole -ApiToken $testApiToken Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -63,8 +63,8 @@ Describe 'Get-TeamViewerUserRole' { } It 'Should return Role objects' { - $result = Get-TeamViewerUserRole -ApiToken $testApiToken + $result = Get-TeamViewerRole -ApiToken $testApiToken $result | Should -HaveCount 2 - $result[0].PSObject.TypeNames | Should -Contain 'TeamViewerPS.UserRole' + $result[0].PSObject.TypeNames | Should -Contain 'TeamViewerPS.Role' } } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 index 7a330ff..eceea2b 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerRoleAssignmentToAccount.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUserByRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -17,20 +17,19 @@ BeforeAll { $null = $testUserRoleId } -Describe 'Get-TeamViewerRoleAssignmentToAccount' { +Describe 'Get-TeamViewerUserByRole' { Context 'When retrieving role assignments' { It 'Should call the correct API endpoint' { - Get-TeamViewerRoleAssignmentToAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId + Get-TeamViewerUserByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/assignments/account?userRoleId=$testUserRoleId" -And ` - $Method -eq 'Get' + $Uri -eq "//unit.test/userroles/assignments/account?userRoleId=$testUserRoleId" -And $Method -eq 'Get' } } It 'Should return assigned users' { - $result = Get-TeamViewerRoleAssignmentToAccount -ApiToken $testApiToken -UserRoleId $testUserRoleId + $result = Get-TeamViewerUserByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId $result | Should -HaveCount 2 } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 index 94593b9..b867b61 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerRoleAssignmentToUserGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerUserGroupByRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -8,7 +8,7 @@ BeforeAll { $Assigned = @('1001', '1002') Mock Invoke-TeamViewerRestMethod { @{ ContinuationToken = $null - AssignedToGroups = $Assigned + AssignedToGroups = $Assigned } } $testApiToken = [securestring]@{} @@ -17,10 +17,10 @@ BeforeAll { $null = $testUserRoleId } -Describe 'Get-TeamViewerRoleAssignmentTouserGroup' { +Describe 'Get-TeamViewerUserGroupByRole' { Context 'When retrieving role assignments' { It 'Should call the correct API endpoint' { - Get-TeamViewerRoleAssignmentToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId + Get-TeamViewerUserGroupByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -30,7 +30,7 @@ Describe 'Get-TeamViewerRoleAssignmentTouserGroup' { } It 'Should return assigned groups' { - $result = Get-TeamViewerRoleAssignmentToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId + $result = Get-TeamViewerUserGroupByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId $result | Should -HaveCount 2 } diff --git a/Tests/Public/New-TeamViewerUserRole.tests.ps1 b/Tests/Public/New-TeamViewerRole.tests.ps1 similarity index 78% rename from Tests/Public/New-TeamViewerUserRole.tests.ps1 rename to Tests/Public/New-TeamViewerRole.tests.ps1 index 085e3e9..98e7f09 100644 --- a/Tests/Public/New-TeamViewerUserRole.tests.ps1 +++ b/Tests/Public/New-TeamViewerRole.tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\New-TeamViewerRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } @@ -23,9 +23,9 @@ BeforeAll { } } -Describe 'New-TeamViewerUserRole' { +Describe 'New-TeamViewerRole' { It 'Should call the correct API endpoint' { - New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName + New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -35,7 +35,7 @@ Describe 'New-TeamViewerUserRole' { } It 'Should include the given name in the request' { - New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName + New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -43,7 +43,7 @@ Describe 'New-TeamViewerUserRole' { } It 'Should include the given permissions in the request' { - New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions + New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -51,10 +51,10 @@ Describe 'New-TeamViewerUserRole' { } It 'Should return a UserRole object' { - $result = New-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions + $result = New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions $result | Should -Not -BeNullOrEmpty $result | Should -BeOfType [PSObject] - $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.UserRole' + $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.Role' $result.RoleName | Should -Be $testUserRoleName foreach ($Rule in $result.Permissions) { $result.Permissions.$Rule | Should -Be $testPermissions diff --git a/Tests/Public/Remove-TeamViewerAccountFromUserRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 similarity index 83% rename from Tests/Public/Remove-TeamViewerAccountFromUserRole.Tests.ps1 rename to Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 index 6d544ae..d388dc9 100644 --- a/Tests/Public/Remove-TeamViewerAccountFromUserRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerAccountFromUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserFromRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -19,10 +19,10 @@ BeforeAll { } } } -Describe 'Remove-TeamViewerAccountFromUserRole' { +Describe 'Remove-TeamViewerUserFromRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerAccountFromUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Remove-TeamViewerUserFromRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -32,7 +32,7 @@ Describe 'Remove-TeamViewerAccountFromUserRole' { } It 'Should unassign the given account from the user role' { - Remove-TeamViewerAccountFromUserRole ` + Remove-TeamViewerUserFromRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId ` -Accounts $testAccount @@ -46,7 +46,7 @@ Describe 'Remove-TeamViewerAccountFromUserRole' { } It 'Should accept pipeline input' { - $testAccount | Remove-TeamViewerAccountFromUserRole ` + $testAccount | Remove-TeamViewerUserFromRole ` -ApiToken $testApiToken ` -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty diff --git a/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 similarity index 76% rename from Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 rename to Tests/Public/Remove-TeamViewerRole.Tests.ps1 index eb9bd07..eadd7d8 100644 --- a/Tests/Public/Remove-TeamViewerUserRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 @@ -1,6 +1,6 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -13,9 +13,9 @@ BeforeAll { Mock Get-TeamViewerApiUri { '//unit.test' } Mock Invoke-TeamViewerRestMethod {} } -Describe 'Remove-TeamViewerUserRole' { +Describe 'Remove-TeamViewerRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerUserRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + Remove-TeamViewerRole -ApiToken $testApiToken -UserRoleId $testUserRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -25,8 +25,8 @@ Describe 'Remove-TeamViewerUserRole' { } It 'Should handle domain object as input' { - $testUserRole = @{Id = $testUserRoleId; Name = 'test user role' } | ConvertTo-TeamViewerUserRole - Remove-TeamViewerUserRole -ApiToken $testApiToken -UserRoleId $testUserRole.RoleID + $testUserRole = @{Id = $testUserRoleId; Name = 'test user role' } | ConvertTo-TeamViewerRole + Remove-TeamViewerRole -ApiToken $testApiToken -UserRoleId $testUserRole.RoleID Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` diff --git a/Tests/Public/Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserGroupFromRole.Tests.ps1 similarity index 84% rename from Tests/Public/Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 rename to Tests/Public/Remove-TeamViewerUserGroupFromRole.Tests.ps1 index b2a42bb..6d5d89b 100644 --- a/Tests/Public/Remove-TeamViewerUserGroupFromUserRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerUserGroupFromRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserGroupFromUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerUserGroupFromRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -17,10 +17,10 @@ BeforeAll { } } } -Describe 'Remove-TeamViewerUserGroupFromUserRole' { +Describe 'Remove-TeamViewerUserGroupFromRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerUserGroupFromUserRole -ApiToken $testApiToken -UserGroup $testUserGroup + Remove-TeamViewerUserGroupFromRole -ApiToken $testApiToken -UserGroup $testUserGroup Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -30,7 +30,7 @@ Describe 'Remove-TeamViewerUserGroupFromUserRole' { } It 'Should unassign the given user group from the user role' { - Remove-TeamViewerUserGroupFromUserRole ` + Remove-TeamViewerUserGroupFromRole ` -ApiToken $testApiToken ` -UserGroup $testUserGroup $mockArgs.Body | Should -Not -BeNullOrEmpty diff --git a/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 b/Tests/Public/Set-TeamViewerRole.Tests.ps1 similarity index 80% rename from Tests/Public/Set-TeamViewerUserRole.Tests.ps1 rename to Tests/Public/Set-TeamViewerRole.Tests.ps1 index 2c3839e..6a180b1 100644 --- a/Tests/Public/Set-TeamViewerUserRole.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerRole.Tests.ps1 @@ -1,5 +1,5 @@ BeforeAll { - . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerUserRole.ps1" + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerRole.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ForEach-Object { . $_.FullName } @@ -25,9 +25,9 @@ BeforeAll { } } -Describe 'Set-TeamViewerUserRole' { +Describe 'Set-TeamViewerRole' { It 'Should call the correct API endpoint' { - Set-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -37,7 +37,7 @@ Describe 'Set-TeamViewerUserRole' { } It 'Should include the given name in the request' { - Set-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -45,7 +45,7 @@ Describe 'Set-TeamViewerUserRole' { } It 'Should include the given permissions in the request' { - Set-TeamViewerUserRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions -UserRoleId $testUserRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions -UserRoleId $testUserRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -56,10 +56,10 @@ Describe 'Set-TeamViewerUserRole' { #Request doesn't return a response body # } - It 'Should change user role properties' { + It 'Should change role properties' { $TestNameChange = 'Test1234' $testPermissionsChange = 'ModifyConnections' - Set-TeamViewerUserRole ` + Set-TeamViewerRole ` -ApiToken $testApiToken ` -Name $TestNameChange ` -Permissions $testPermissionsChange ` From 6e13b7237e34b00586b56ed7c5fb989359cd9dcf Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Fri, 20 Oct 2023 19:25:28 +0200 Subject: [PATCH 089/110] Fix variable --- Cmdlets/Public/Add-TeamViewerUserToRole.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 index 55b5f1c..2efe0d9 100644 --- a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 @@ -18,7 +18,7 @@ function Add-TeamViewerUserToRole { ) Begin { - $id = D | Resolve-TeamViewerRoleId + $id = $RoleId | Resolve-TeamViewerRoleId $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" $AccountsToAdd = @() From 14d2d4698ecbfaa85f10f67bca222b690fbf6583 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Fri, 20 Oct 2023 19:37:14 +0200 Subject: [PATCH 090/110] Fix parameters and variable names --- .../Public/Add-TeamViewerUserGroupToRole.ps1 | 4 ++-- Cmdlets/Public/Add-TeamViewerUserToRole.ps1 | 2 +- .../Public/Remove-TeamViewerUserFromRole.ps1 | 2 +- Cmdlets/Public/Set-TeamViewerRole.ps1 | 2 +- Docs/Help/Add-TeamViewerUserToRole.md | 6 +++--- Docs/Help/Get-TeamViewerUserByRole.md | 6 +++--- Docs/Help/Get-TeamViewerUserGroupByRole.md | 6 +++--- Docs/Help/Remove-TeamViewerPredefinedRole.md | 2 +- Docs/Help/Remove-TeamViewerUserFromRole.md | 12 ++++++------ Docs/Help/Remove-TeamViewerUserRole.md | 8 ++++---- Docs/Help/Set-TeamViewerUserRole.md | 6 +++--- .../Add-TeamViewerUserGroupToRole.Tests.ps1 | 8 ++++---- .../Public/Add-TeamViewerUserToRole.Tests.ps1 | 18 +++++++++--------- ...TeamViewerRoleAssignmentToAccount.Tests.ps1 | 10 +++++----- ...amViewerRoleAssignmentToUserGroup.Tests.ps1 | 10 +++++----- .../Remove-TeamViewerAccountFromRole.Tests.ps1 | 18 +++++++++--------- Tests/Public/Remove-TeamViewerRole.Tests.ps1 | 14 +++++++------- .../Set-TeamViewerPredefinedRole.Tests.ps1 | 8 ++++---- Tests/Public/Set-TeamViewerRole.Tests.ps1 | 14 +++++++------- 19 files changed, 78 insertions(+), 78 deletions(-) diff --git a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 index 17c4fdf..d597570 100644 --- a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 @@ -7,7 +7,7 @@ function Add-TeamViewerUserGroupToRole { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] - [Alias('UserRoleId')] + [Alias('RoleId')] [object] $UserRole, @@ -24,7 +24,7 @@ function Add-TeamViewerUserGroupToRole { $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ - UserRoleId = $RoleId + RoleId = $RoleId UserGroupId = $UserGroup } diff --git a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 index 2efe0d9..78660a4 100644 --- a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 @@ -24,7 +24,7 @@ function Add-TeamViewerUserToRole { $AccountsToAdd = @() $body = @{ UserIds = @() - UserRoleId = $id + RoleId = $id } function Invoke-TeamViewerRestMethodInternal { $result = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 index 4861e96..cf79e33 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 @@ -24,7 +24,7 @@ function Remove-TeamViewerUserFromRole { $AccountsToRemove = @() $body = @{ UserIds = @() - UserRoleId = $id + RoleId = $id } function Invoke-TeamViewerRestMethodInternal { $result = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Set-TeamViewerRole.ps1 b/Cmdlets/Public/Set-TeamViewerRole.ps1 index c495441..3a6d454 100644 --- a/Cmdlets/Public/Set-TeamViewerRole.ps1 +++ b/Cmdlets/Public/Set-TeamViewerRole.ps1 @@ -27,7 +27,7 @@ function Set-TeamViewerRole { $body = @{ Name = $Name Permissions = @() - UserRoleId = $RoleId + RoleId = $RoleId } if ($Permissions) { diff --git a/Docs/Help/Add-TeamViewerUserToRole.md b/Docs/Help/Add-TeamViewerUserToRole.md index 8bc5c46..15ff3cc 100644 --- a/Docs/Help/Add-TeamViewerUserToRole.md +++ b/Docs/Help/Add-TeamViewerUserToRole.md @@ -14,7 +14,7 @@ Assign a list of accountIds to a role. ## SYNTAX ```powershell -Add-TeamViewerUserToRole [-ApiToken] [-UserRoleId] [-Account] [-WhatIf] +Add-TeamViewerUserToRole [-ApiToken] [-RoleId] [-Account] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Assigns one or many users to a role. A role should belong to the TeamViewer comp ### Example 1 ```powershell -PS /> Add-TeamViewerUserToRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Add-TeamViewerUserToRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. @@ -75,7 +75,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRoleId +### -RoleId the role to which users will be assigned to. diff --git a/Docs/Help/Get-TeamViewerUserByRole.md b/Docs/Help/Get-TeamViewerUserByRole.md index 80136ee..6bf1dc4 100644 --- a/Docs/Help/Get-TeamViewerUserByRole.md +++ b/Docs/Help/Get-TeamViewerUserByRole.md @@ -14,7 +14,7 @@ Lists users assigned to one specific role. ## SYNTAX ```powershell -Get-TeamViewerUserByRole [-ApiToken] [-UserRoleId] [] +Get-TeamViewerUserByRole [-ApiToken] [-RoleId] [] ``` ## DESCRIPTION @@ -26,7 +26,7 @@ Lists all users of role in the TeamViewer company associated with the API access ### Example 1 ```powershell -PS /> Get-TeamViewerUserByRole -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' +PS /> Get-TeamViewerUserByRole -RoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' ``` Lists all users of the ole `72abbedc-9853-4fc8-9d28-fa35e207b048`. @@ -49,7 +49,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRoleId +### -RoleId UserRole to list its assigned users. diff --git a/Docs/Help/Get-TeamViewerUserGroupByRole.md b/Docs/Help/Get-TeamViewerUserGroupByRole.md index 12ef9fb..b56f537 100644 --- a/Docs/Help/Get-TeamViewerUserGroupByRole.md +++ b/Docs/Help/Get-TeamViewerUserGroupByRole.md @@ -14,7 +14,7 @@ Lists all user group assignments of a user role. ## SYNTAX ```powershell -Get-TeamViewerUserGroupByRole [-ApiToken] [-UserRoleId] [] +Get-TeamViewerUserGroupByRole [-ApiToken] [-RoleId] [] ``` ## DESCRIPTION @@ -26,7 +26,7 @@ Lists all user groups of role in the TeamViewer company associated with the API ### Example 1 ```powershell -PS /> Get-TeamViewerUserGroupByRole -UserRoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' +PS /> Get-TeamViewerUserGroupByRole -RoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' ``` Lists all user groups of the role `72abbedc-9853-4fc8-9d28-fa35e207b048`. @@ -49,7 +49,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRoleId +### -RoleId UserRole to list its assigned users. diff --git a/Docs/Help/Remove-TeamViewerPredefinedRole.md b/Docs/Help/Remove-TeamViewerPredefinedRole.md index 5ed3d86..e7c8f11 100644 --- a/Docs/Help/Remove-TeamViewerPredefinedRole.md +++ b/Docs/Help/Remove-TeamViewerPredefinedRole.md @@ -14,7 +14,7 @@ Remove existing predefined role. ## SYNTAX ```powershell -Remove-TeamViewerPredefinedRole [-ApiToken] [-UserRoleId] [-WhatIf] [-Confirm] +Remove-TeamViewerPredefinedRole [-ApiToken] [-RoleId] [-WhatIf] [-Confirm] [] ``` diff --git a/Docs/Help/Remove-TeamViewerUserFromRole.md b/Docs/Help/Remove-TeamViewerUserFromRole.md index 3066182..be0acf9 100644 --- a/Docs/Help/Remove-TeamViewerUserFromRole.md +++ b/Docs/Help/Remove-TeamViewerUserFromRole.md @@ -13,17 +13,17 @@ Un-assigns one or many users from a role. ## SYNTAX -### ByUserRoleIdMemberId (All) +### ByRoleIdMemberId (All) ```powershell -Remove-TeamViewerUserFromRole [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerUserFromRole [-ApiToken] [-RoleId] [-Account] [-WhatIf] [-Confirm] [] ``` ### ByUserId ```powershell -Remove-TeamViewerUserFromRole [-ApiToken] [-UserRoleId] [-Account] +Remove-TeamViewerUserFromRole [-ApiToken] [-RoleId] [-Account] [-WhatIf] [-Confirm] [] ``` @@ -36,7 +36,7 @@ Un-assigns one or many users from a role. A role belongs to the TeamViewer compa ### Example 1 ```powershell -PS /> Remove-TeamViewerUserFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') +PS /> Remove-TeamViewerUserFromRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' -Account @('123', '456', '789') ``` Un-assigns users with id `123`, `456`, `789` from the role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. @@ -44,7 +44,7 @@ Un-assigns users with id `123`, `456`, `789` from the role with id `9b465ea2-2f7 ### Example 2 ```powershell -PS /> @('123', '456', '789') | Remove-TeamViewerUserFromRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Remove-TeamViewerUserFromRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Un-assigns users with id `123`, `456`, `789` from role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. @@ -84,7 +84,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRoleId +### -RoleId The role where users will be unassigned from. diff --git a/Docs/Help/Remove-TeamViewerUserRole.md b/Docs/Help/Remove-TeamViewerUserRole.md index bf37f64..af83ef5 100644 --- a/Docs/Help/Remove-TeamViewerUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserRole.md @@ -14,7 +14,7 @@ Deletes one specific role from the TeamViewer company. ## SYNTAX ```powershell -Remove-TeamViewerRole [-ApiToken] [-UserRoleId] [-WhatIf] [-Confirm] +Remove-TeamViewerRole [-ApiToken] [-RoleId] [-WhatIf] [-Confirm] [] ``` @@ -28,7 +28,7 @@ All permissions and user assignments of the role will be deleted too. ### Example 1 ```powershell -PS /> Remove-TeamViewerRole -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> Remove-TeamViewerRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Deletes the role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. @@ -36,7 +36,7 @@ Deletes the role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. ### Example 2 ```powershell -PS /> Remove-TeamViewerRole -UserRoleId (Get-TeamViewerRole | Where-Object { ($_.RoleName -eq 'Test Role') } ).RoleID +PS /> Remove-TeamViewerRole -RoleId (Get-TeamViewerRole | Where-Object { ($_.RoleName -eq 'Test Role') } ).RoleID ``` Deletes a role with the role Id retrieved from `Get-TeamViewerRole` as input. @@ -76,7 +76,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRoleId +### -RoleId The role to be deleted. diff --git a/Docs/Help/Set-TeamViewerUserRole.md b/Docs/Help/Set-TeamViewerUserRole.md index 2d2cb7b..81fbb1a 100644 --- a/Docs/Help/Set-TeamViewerUserRole.md +++ b/Docs/Help/Set-TeamViewerUserRole.md @@ -14,7 +14,7 @@ Update properties of a user role. ## SYNTAX ```powershell -Set-TeamViewerRole [-ApiToken] [-Name] [-UserRoleId] [-Permissions] [-WhatIf] [-Confirm] [] +Set-TeamViewerRole [-ApiToken] [-Name] [-RoleId] [-Permissions] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -26,7 +26,7 @@ Update properties of a user role. It allows to rename and alter permissions. ### Example 1 ```powershell -PS /> Set-TeamViewerRole -Name 'New name of role' -Permissions 'AllowGroupSharing','ModifyConnections' -UserRoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> Set-TeamViewerRole -Name 'New name of role' -Permissions 'AllowGroupSharing','ModifyConnections' -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Renames the role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to `New name of role` and enables the permissions `AllowGroupSharing` and `ModifyConnections`. @@ -65,7 +65,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRoleId +### -RoleId The role to be updated. diff --git a/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 index ba0e965..53cd28e 100644 --- a/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 @@ -7,20 +7,20 @@ BeforeAll { $null = $testApiToken $testUserGroup = 1234 $null = $testUserGroup - $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' - $null = $testUserRoleId + $testRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testRoleId Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @{ - UserRoleId = $testUserRoleId + RoleId = $testRoleId UserGroupId = $testUserGroup } } } Describe 'Add-TeamViewerUserGroupToRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerUserGroupToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Add-TeamViewerUserGroupToRole -ApiToken $testApiToken -RoleId $testRoleId -UserGroup $testUserGroup Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 index 693bebf..dcd0f0b 100644 --- a/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 @@ -7,22 +7,22 @@ BeforeAll { $null = $testApiToken $testAccount = @('u123', 'u124') $null = $testAccount - $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' - $null = $testUserRoleId + $testRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testRoleId Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @{ - UserIds = @($testAccount) - UserRoleId = $testUserRoleId + UserIds = @($testAccount) + RoleId = $testRoleId } } } Describe 'Add-TeamViewerUserToRole' { It 'Should call the correct API endpoint' { - Add-TeamViewerUserToRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Add-TeamViewerUserToRole -ApiToken $testApiToken -RoleId $testRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -35,7 +35,7 @@ Describe 'Add-TeamViewerUserToRole' { It 'Should assign the given account to the user role' { Add-TeamViewerUserToRole ` -ApiToken $testApiToken ` - -UserRoleId $testUserRoleId ` + -RoleId $testRoleId ` -Accounts $testAccount $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -43,19 +43,19 @@ Describe 'Add-TeamViewerUserToRole' { foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.UserRoleId | Should -Be $testUserRoleId + $body.RoleId | Should -Be $testRoleId } It 'Should accept pipeline input' { $testAccount | Add-TeamViewerUserToRole ` -ApiToken $testApiToken ` - -UserRoleId $testUserRoleId + -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json $body.UserIds | Should -HaveCount 2 foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.UserRoleId | Should -Be $testUserRoleId + $body.RoleId | Should -Be $testRoleId } } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 index eceea2b..a781eb1 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 @@ -13,23 +13,23 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken - $testUserRoleId = '72abbedc-9853-4fc8-9d28-fa35e207b048' - $null = $testUserRoleId + $testRoleId = '72abbedc-9853-4fc8-9d28-fa35e207b048' + $null = $testRoleId } Describe 'Get-TeamViewerUserByRole' { Context 'When retrieving role assignments' { It 'Should call the correct API endpoint' { - Get-TeamViewerUserByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + Get-TeamViewerUserByRole -ApiToken $testApiToken -RoleId $testRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/assignments/account?userRoleId=$testUserRoleId" -And $Method -eq 'Get' + $Uri -eq "//unit.test/userroles/assignments/account?RoleId=$testRoleId" -And $Method -eq 'Get' } } It 'Should return assigned users' { - $result = Get-TeamViewerUserByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + $result = Get-TeamViewerUserByRole -ApiToken $testApiToken -RoleId $testRoleId $result | Should -HaveCount 2 } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 index b867b61..bdab9ae 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 @@ -13,24 +13,24 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken - $testUserRoleId = '72abbedc-9853-4fc8-9d28-fa35e207b048' - $null = $testUserRoleId + $testRoleId = '72abbedc-9853-4fc8-9d28-fa35e207b048' + $null = $testRoleId } Describe 'Get-TeamViewerUserGroupByRole' { Context 'When retrieving role assignments' { It 'Should call the correct API endpoint' { - Get-TeamViewerUserGroupByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + Get-TeamViewerUserGroupByRole -ApiToken $testApiToken -RoleId $testRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/assignments/usergroups?userRoleId=$testUserRoleId" -And ` + $Uri -eq "//unit.test/userroles/assignments/usergroups?RoleId=$testRoleId" -And ` $Method -eq 'Get' } } It 'Should return assigned groups' { - $result = Get-TeamViewerUserGroupByRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + $result = Get-TeamViewerUserGroupByRole -ApiToken $testApiToken -RoleId $testRoleId $result | Should -HaveCount 2 } diff --git a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 index d388dc9..b0a816b 100644 --- a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 @@ -7,22 +7,22 @@ BeforeAll { $null = $testApiToken $testAccount = @('u123', 'u124') $null = $testAccount - $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' - $null = $testUserRoleId + $testRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testRoleId Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @{ - UserIds = @($testAccount) - UserRoleId = $testUserRoleId + UserIds = @($testAccount) + RoleId = $testRoleId } } } Describe 'Remove-TeamViewerUserFromRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerUserFromRole -ApiToken $testApiToken -UserRoleId $testUserRoleId -Accounts $testAccount + Remove-TeamViewerUserFromRole -ApiToken $testApiToken -RoleId $testRoleId -Accounts $testAccount Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -34,7 +34,7 @@ Describe 'Remove-TeamViewerUserFromRole' { It 'Should unassign the given account from the user role' { Remove-TeamViewerUserFromRole ` -ApiToken $testApiToken ` - -UserRoleId $testUserRoleId ` + -UserRoleId $testRoleId ` -Accounts $testAccount $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -42,19 +42,19 @@ Describe 'Remove-TeamViewerUserFromRole' { foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.UserRoleId | Should -Be $testUserRoleId + $body.RoleId | Should -Be $testRoleId } It 'Should accept pipeline input' { $testAccount | Remove-TeamViewerUserFromRole ` -ApiToken $testApiToken ` - -UserRoleId $testUserRoleId + -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json $body.UserIds | Should -HaveCount 2 foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.UserRoleId | Should -Be $testUserRoleId + $body.RoleId | Should -Be $testRoleId } } diff --git a/Tests/Public/Remove-TeamViewerRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 index eadd7d8..52f0059 100644 --- a/Tests/Public/Remove-TeamViewerRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 @@ -7,30 +7,30 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken - $testUserRoleId = '2bcf19dc-d5a9-4d25-952e-7cbb21762c9a' - $null = $testUserRoleId + $testRoleId = '2bcf19dc-d5a9-4d25-952e-7cbb21762c9a' + $null = $testRoleId Mock Get-TeamViewerApiUri { '//unit.test' } Mock Invoke-TeamViewerRestMethod {} } Describe 'Remove-TeamViewerRole' { It 'Should call the correct API endpoint' { - Remove-TeamViewerRole -ApiToken $testApiToken -UserRoleId $testUserRoleId + Remove-TeamViewerRole -ApiToken $testApiToken -RoleId $testRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles?userRoleId=$testUserRoleId" -And ` + $Uri -eq "//unit.test/userroles?RoleId=$testRoleId" -And ` $Method -eq 'Delete' } } It 'Should handle domain object as input' { - $testUserRole = @{Id = $testUserRoleId; Name = 'test user role' } | ConvertTo-TeamViewerRole - Remove-TeamViewerRole -ApiToken $testApiToken -UserRoleId $testUserRole.RoleID + $testUserRole = @{Id = $testRoleId; Name = 'test user role' } | ConvertTo-TeamViewerRole + Remove-TeamViewerRole -ApiToken $testApiToken -RoleId $testUserRole.RoleID Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles?userRoleId=$testUserRoleId" -And ` + $Uri -eq "//unit.test/userroles?RoleId=$testRoleId" -And ` $Method -eq 'Delete' } } diff --git a/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 b/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 index dc9ecec..10915b4 100644 --- a/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerPredefinedRole.Tests.ps1 @@ -5,8 +5,8 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken - $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' - $null = $testUserRoleId + $testRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testRoleId Mock Get-TeamViewerApiUri { '//unit.test' } Mock Invoke-TeamViewerRestMethod @@ -14,11 +14,11 @@ BeforeAll { Describe 'Set-TeamViewerPredefinedRole' { It 'Should call the correct API endpoint' { - Set-TeamViewerPredefinedRole -ApiToken $testApiToken -RoleId $testUserRoleId + Set-TeamViewerPredefinedRole -ApiToken $testApiToken -RoleId $testRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/$testUserRoleId/predefined" -And ` + $Uri -eq "//unit.test/userroles/$testRoleId/predefined" -And ` $Method -eq 'Put' } } diff --git a/Tests/Public/Set-TeamViewerRole.Tests.ps1 b/Tests/Public/Set-TeamViewerRole.Tests.ps1 index 6a180b1..9651529 100644 --- a/Tests/Public/Set-TeamViewerRole.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerRole.Tests.ps1 @@ -10,8 +10,8 @@ BeforeAll { $null = $testUserRoleName $testPermissions = 'AllowGroupSharing', 'AssignBackupPolicies' $null = $testPermissions - $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' - $null = $testUserRoleId + $testRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' + $null = $testRoleId Mock Get-TeamViewerApiUri { '//unit.test' } Mock Invoke-TeamViewerRestMethod { @@ -19,7 +19,7 @@ BeforeAll { @{ Name = $testUserRoleName Permissions = @($testPermissions) - UserRoleId = $testUserRoleId + RoleId = $testRoleId } } @@ -27,7 +27,7 @@ BeforeAll { Describe 'Set-TeamViewerRole' { It 'Should call the correct API endpoint' { - Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -RoleId $testRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -37,7 +37,7 @@ Describe 'Set-TeamViewerRole' { } It 'Should include the given name in the request' { - Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -UserRoleId $testUserRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -45,7 +45,7 @@ Describe 'Set-TeamViewerRole' { } It 'Should include the given permissions in the request' { - Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions -UserRoleId $testUserRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -63,7 +63,7 @@ Describe 'Set-TeamViewerRole' { -ApiToken $testApiToken ` -Name $TestNameChange ` -Permissions $testPermissionsChange ` - -UserRoleId $testUserRoleId + -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json $body.Name | Should -Be 'Test1234' From 84dec6dfb0be184eac9866b7e55e7dba4dd40544 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Fri, 20 Oct 2023 20:06:13 +0200 Subject: [PATCH 091/110] Fixing tests --- .../Public/Add-TeamViewerUserGroupToRole.ps1 | 6 +++--- Cmdlets/Public/Add-TeamViewerUserToRole.ps1 | 6 +++--- Cmdlets/Public/Get-TeamViewerUserByRole.ps1 | 2 +- .../Public/Get-TeamViewerUserGroupByRole.ps1 | 2 +- Cmdlets/Public/New-TeamViewerRole.ps1 | 2 +- Cmdlets/Public/Remove-TeamViewerRole.ps1 | 2 +- .../Public/Remove-TeamViewerUserFromRole.ps1 | 6 +++--- Cmdlets/Public/Set-TeamViewerRole.ps1 | 4 ++-- Docs/Help/Add-TeamViewerUserGroupToUserRole.md | 8 ++++---- Docs/Help/Add-TeamViewerUserToRole.md | 4 ++-- Docs/Help/Get-TeamViewerUserByRole.md | 4 ++-- Docs/Help/Get-TeamViewerUserGroupByRole.md | 4 ++-- Docs/Help/Remove-TeamViewerUserFromRole.md | 2 +- Docs/Help/Remove-TeamViewerUserRole.md | 2 +- Docs/Help/Set-TeamViewerPredefinedRole.md | 2 +- Docs/Help/Set-TeamViewerUserRole.md | 4 ++-- .../Add-TeamViewerUserGroupToRole.Tests.ps1 | 2 +- ....ps1 => Get-TeamViewerUserByRole.Tests.ps1} | 3 ++- ...=> Get-TeamViewerUserGroupByRole.Tests.ps1} | 0 Tests/Public/New-TeamViewerRole.tests.ps1 | 18 +++++++++--------- .../Remove-TeamViewerAccountFromRole.Tests.ps1 | 2 +- Tests/Public/Remove-TeamViewerRole.Tests.ps1 | 4 ++-- Tests/Public/Set-TeamViewerRole.Tests.ps1 | 16 ++++++++-------- 23 files changed, 53 insertions(+), 52 deletions(-) rename Tests/Public/{Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 => Get-TeamViewerUserByRole.Tests.ps1} (94%) rename Tests/Public/{Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 => Get-TeamViewerUserGroupByRole.Tests.ps1} (100%) diff --git a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 index d597570..9b12ff7 100644 --- a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 @@ -9,7 +9,7 @@ function Add-TeamViewerUserGroupToRole { [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] [Alias('RoleId')] [object] - $UserRole, + $Role, [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] @@ -20,11 +20,11 @@ function Add-TeamViewerUserGroupToRole { ) Begin { - $RoleId = $UserRole | Resolve-TeamViewerRoleId + $RoleId = $Role | Resolve-TeamViewerRoleId $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ - RoleId = $RoleId + RoleId = $RoleId UserGroupId = $UserGroup } diff --git a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 index 78660a4..f6fb2e1 100644 --- a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 @@ -7,7 +7,7 @@ function Add-TeamViewerUserToRole { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] - [Alias('UserRole')] + [Alias('Role')] [object] $RoleId, @@ -23,8 +23,8 @@ function Add-TeamViewerUserToRole { $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" $AccountsToAdd = @() $body = @{ - UserIds = @() - RoleId = $id + UserIds = @() + RoleId = $id } function Invoke-TeamViewerRestMethodInternal { $result = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Get-TeamViewerUserByRole.ps1 b/Cmdlets/Public/Get-TeamViewerUserByRole.ps1 index e7d9175..4aea9de 100644 --- a/Cmdlets/Public/Get-TeamViewerUserByRole.ps1 +++ b/Cmdlets/Public/Get-TeamViewerUserByRole.ps1 @@ -6,7 +6,7 @@ function Get-TeamViewerUserByRole { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] - [Alias('UserRole')] + [Alias('Role')] [string] $RoleId ) diff --git a/Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 b/Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 index d8cb9b4..9ec3738 100644 --- a/Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 +++ b/Cmdlets/Public/Get-TeamViewerUserGroupByRole.ps1 @@ -6,7 +6,7 @@ function Get-TeamViewerUserGroupByRole { [Parameter(Mandatory = $true)] [ValidateScript({ $_ | Resolve-TeamViewerRoleId })] - [Alias('UserRole')] + [Alias('Role')] [string] $RoleId ) diff --git a/Cmdlets/Public/New-TeamViewerRole.ps1 b/Cmdlets/Public/New-TeamViewerRole.ps1 index 487896b..bf1d695 100644 --- a/Cmdlets/Public/New-TeamViewerRole.ps1 +++ b/Cmdlets/Public/New-TeamViewerRole.ps1 @@ -7,7 +7,7 @@ function New-TeamViewerRole { $ApiToken, [Parameter(Mandatory = $true)] - [Alias('UserRoleName')] + [Alias('RoleName')] [string] $Name, diff --git a/Cmdlets/Public/Remove-TeamViewerRole.ps1 b/Cmdlets/Public/Remove-TeamViewerRole.ps1 index df5e7f7..6c7bce7 100644 --- a/Cmdlets/Public/Remove-TeamViewerRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerRole.ps1 @@ -7,7 +7,7 @@ function Remove-TeamViewerRole { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] - [Alias('UserRole')] + [Alias('Role')] [Alias('Id')] [object] $RoleId diff --git a/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 index cf79e33..3f07a28 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 @@ -7,7 +7,7 @@ function Remove-TeamViewerUserFromRole { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] - [Alias('UserRole')] + [Alias('Role')] [object] $RoleId, @@ -23,8 +23,8 @@ function Remove-TeamViewerUserFromRole { $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" $AccountsToRemove = @() $body = @{ - UserIds = @() - RoleId = $id + UserIds = @() + RoleId = $id } function Invoke-TeamViewerRestMethodInternal { $result = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Set-TeamViewerRole.ps1 b/Cmdlets/Public/Set-TeamViewerRole.ps1 index 3a6d454..4f740b9 100644 --- a/Cmdlets/Public/Set-TeamViewerRole.ps1 +++ b/Cmdlets/Public/Set-TeamViewerRole.ps1 @@ -7,7 +7,7 @@ function Set-TeamViewerRole { $ApiToken, [Parameter(Mandatory = $true)] - [Alias('UserRoleName')] + [Alias('RoleName')] [string] $Name, @@ -18,7 +18,7 @@ function Set-TeamViewerRole { [Parameter(Mandatory = $true)] [ValidateScript( { $_ | Resolve-TeamViewerRoleId } )] - [Alias('UserRole')] + [Alias('Role')] [object] $RoleId ) diff --git a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md index 4bbad69..fdf5aae 100644 --- a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md +++ b/Docs/Help/Add-TeamViewerUserGroupToUserRole.md @@ -14,7 +14,7 @@ Assign a user group to a role. ## SYNTAX ```powershell -Add-TeamViewerUserGroupToRole [-ApiToken] [-UserRole] [-UserGroup] [-WhatIf] +Add-TeamViewerUserGroupToRole [-ApiToken] [-Role] [-UserGroup] [-WhatIf] [-Confirm] [] ``` @@ -27,7 +27,7 @@ Assigns a user group to a role of the TeamViewer company associated with the API ### Example 1 ```powershell -PS /> Add-TeamViewerUserGroupToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 +PS /> Add-TeamViewerUserGroupToRole -Role '9b465ea2-2f75-4101-a057-58a81ed0e57b' -UserGroup 1001 ``` The given user group `1001` gets assigned to the role with Id `9b465ea2-2f75-4101-a057-58a81ed0e57b`. @@ -66,14 +66,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserRole +### -Role The role to be assigned to the accountIds ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: 1 diff --git a/Docs/Help/Add-TeamViewerUserToRole.md b/Docs/Help/Add-TeamViewerUserToRole.md index 15ff3cc..146dbdb 100644 --- a/Docs/Help/Add-TeamViewerUserToRole.md +++ b/Docs/Help/Add-TeamViewerUserToRole.md @@ -35,7 +35,7 @@ Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `12 ### Example 2 ```powershell -PS /> @('123', '456', '789') | Add-TeamViewerUserToRole -UserRole '9b465ea2-2f75-4101-a057-58a81ed0e57b' +PS /> @('123', '456', '789') | Add-TeamViewerUserToRole -Role '9b465ea2-2f75-4101-a057-58a81ed0e57b' ``` Assigns role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` to users with id `123`, `456`, `789`. @@ -82,7 +82,7 @@ the role to which users will be assigned to. ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: 1 diff --git a/Docs/Help/Get-TeamViewerUserByRole.md b/Docs/Help/Get-TeamViewerUserByRole.md index 6bf1dc4..0fae67a 100644 --- a/Docs/Help/Get-TeamViewerUserByRole.md +++ b/Docs/Help/Get-TeamViewerUserByRole.md @@ -51,12 +51,12 @@ Accept wildcard characters: False ### -RoleId -UserRole to list its assigned users. +Role to list its assigned users. ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: 1 diff --git a/Docs/Help/Get-TeamViewerUserGroupByRole.md b/Docs/Help/Get-TeamViewerUserGroupByRole.md index b56f537..746e9ca 100644 --- a/Docs/Help/Get-TeamViewerUserGroupByRole.md +++ b/Docs/Help/Get-TeamViewerUserGroupByRole.md @@ -51,12 +51,12 @@ Accept wildcard characters: False ### -RoleId -UserRole to list its assigned users. +Role to list its assigned users. ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: 1 diff --git a/Docs/Help/Remove-TeamViewerUserFromRole.md b/Docs/Help/Remove-TeamViewerUserFromRole.md index be0acf9..b082147 100644 --- a/Docs/Help/Remove-TeamViewerUserFromRole.md +++ b/Docs/Help/Remove-TeamViewerUserFromRole.md @@ -91,7 +91,7 @@ The role where users will be unassigned from. ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: Named diff --git a/Docs/Help/Remove-TeamViewerUserRole.md b/Docs/Help/Remove-TeamViewerUserRole.md index af83ef5..89a6b0a 100644 --- a/Docs/Help/Remove-TeamViewerUserRole.md +++ b/Docs/Help/Remove-TeamViewerUserRole.md @@ -83,7 +83,7 @@ The role to be deleted. ```yaml Type: Object Parameter Sets: (All) -Aliases: Id, UserRole +Aliases: Id, Role Required: True Position: 1 diff --git a/Docs/Help/Set-TeamViewerPredefinedRole.md b/Docs/Help/Set-TeamViewerPredefinedRole.md index 976147a..5dfeb96 100644 --- a/Docs/Help/Set-TeamViewerPredefinedRole.md +++ b/Docs/Help/Set-TeamViewerPredefinedRole.md @@ -65,7 +65,7 @@ The role to be set as Predefined Role. ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: 1 diff --git a/Docs/Help/Set-TeamViewerUserRole.md b/Docs/Help/Set-TeamViewerUserRole.md index 81fbb1a..24793f4 100644 --- a/Docs/Help/Set-TeamViewerUserRole.md +++ b/Docs/Help/Set-TeamViewerUserRole.md @@ -56,7 +56,7 @@ The new name of the User role. ```yaml Type: String Parameter Sets: (All) -Aliases: UserRoleName +Aliases: RoleName Required: True Position: 1 @@ -72,7 +72,7 @@ The role to be updated. ```yaml Type: Object Parameter Sets: (All) -Aliases: UserRole +Aliases: Role Required: True Position: 2 diff --git a/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 index 53cd28e..28218f3 100644 --- a/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserGroupToRole.Tests.ps1 @@ -28,7 +28,7 @@ Describe 'Add-TeamViewerUserGroupToRole' { } } - # It 'Should return a UserRole/UserGroup object' { + # It 'Should return a Role/UserGroup object' { #Request doesn't return a response body # } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 b/Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 similarity index 94% rename from Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 rename to Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 index a781eb1..3b425e3 100644 --- a/Tests/Public/Get-TeamViewerRoleAssignmentToAccount.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 @@ -24,7 +24,8 @@ Describe 'Get-TeamViewerUserByRole' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/assignments/account?RoleId=$testRoleId" -And $Method -eq 'Get' + $Uri -eq "//unit.test/userroles/assignments/account?RoleId=$testRoleId" -And ` + $Method -eq 'Get' } } diff --git a/Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 b/Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 similarity index 100% rename from Tests/Public/Get-TeamViewerRoleAssignmentToUserGroup.Tests.ps1 rename to Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 diff --git a/Tests/Public/New-TeamViewerRole.tests.ps1 b/Tests/Public/New-TeamViewerRole.tests.ps1 index 98e7f09..2705ace 100644 --- a/Tests/Public/New-TeamViewerRole.tests.ps1 +++ b/Tests/Public/New-TeamViewerRole.tests.ps1 @@ -6,7 +6,7 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken $mockArgs = @{} - $testUserRoleName = 'Test Role' + $testRoleName = 'Test Role' $testPermissions = 'AllowGroupSharing', 'AssignBackupPolicies' Mock Get-TeamViewerApiUri { '//unit.test' } @@ -14,7 +14,7 @@ BeforeAll { $mockArgs.Body = $Body @{ Role = @{ - Name = $testUserRoleName + Name = $testRoleName Id = '9b465ea2-2f75-4101-a057-58a81ed0e57b' Permissions = $testPermissions @@ -25,7 +25,7 @@ BeforeAll { Describe 'New-TeamViewerRole' { It 'Should call the correct API endpoint' { - New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName + New-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -35,27 +35,27 @@ Describe 'New-TeamViewerRole' { } It 'Should include the given name in the request' { - New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName + New-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json - $body.Name | Should -Be $testUserRoleName + $body.Name | Should -Be $testRoleName } It 'Should include the given permissions in the request' { - New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions + New-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName -Permissions $testPermissions $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json $body.Permissions | Should -Be $testPermissions } - It 'Should return a UserRole object' { - $result = New-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions + It 'Should return a Role object' { + $result = New-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName -Permissions $testPermissions $result | Should -Not -BeNullOrEmpty $result | Should -BeOfType [PSObject] $result.PSObject.TypeNames | Should -Contain 'TeamViewerPS.Role' - $result.RoleName | Should -Be $testUserRoleName + $result.RoleName | Should -Be $testRoleName foreach ($Rule in $result.Permissions) { $result.Permissions.$Rule | Should -Be $testPermissions } diff --git a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 index b0a816b..aab15fd 100644 --- a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 @@ -34,7 +34,7 @@ Describe 'Remove-TeamViewerUserFromRole' { It 'Should unassign the given account from the user role' { Remove-TeamViewerUserFromRole ` -ApiToken $testApiToken ` - -UserRoleId $testRoleId ` + -RoleId $testRoleId ` -Accounts $testAccount $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json diff --git a/Tests/Public/Remove-TeamViewerRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 index 52f0059..3eb4e8f 100644 --- a/Tests/Public/Remove-TeamViewerRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 @@ -25,8 +25,8 @@ Describe 'Remove-TeamViewerRole' { } It 'Should handle domain object as input' { - $testUserRole = @{Id = $testRoleId; Name = 'test user role' } | ConvertTo-TeamViewerRole - Remove-TeamViewerRole -ApiToken $testApiToken -RoleId $testUserRole.RoleID + $testRole = @{Id = $testRoleId; Name = 'test user role' } | ConvertTo-TeamViewerRole + Remove-TeamViewerRole -ApiToken $testApiToken -RoleId $testRole.RoleID Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` diff --git a/Tests/Public/Set-TeamViewerRole.Tests.ps1 b/Tests/Public/Set-TeamViewerRole.Tests.ps1 index 9651529..029337d 100644 --- a/Tests/Public/Set-TeamViewerRole.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerRole.Tests.ps1 @@ -6,8 +6,8 @@ BeforeAll { $testApiToken = [securestring]@{} $null = $testApiToken $mockArgs = @{} - $testUserRoleName = 'Test Role' - $null = $testUserRoleName + $testRoleName = 'Test Role' + $null = $testRoleName $testPermissions = 'AllowGroupSharing', 'AssignBackupPolicies' $null = $testPermissions $testRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' @@ -17,7 +17,7 @@ BeforeAll { Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @{ - Name = $testUserRoleName + Name = $testRoleName Permissions = @($testPermissions) RoleId = $testRoleId @@ -27,7 +27,7 @@ BeforeAll { Describe 'Set-TeamViewerRole' { It 'Should call the correct API endpoint' { - Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -RoleId $testRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName -RoleId $testRoleId Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` @@ -37,22 +37,22 @@ Describe 'Set-TeamViewerRole' { } It 'Should include the given name in the request' { - Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -RoleId $testRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json - $body.Name | Should -Be $testUserRoleName + $body.Name | Should -Be $testRoleName } It 'Should include the given permissions in the request' { - Set-TeamViewerRole -ApiToken $testApiToken -Name $testUserRoleName -Permissions $testPermissions -RoleId $testRoleId + Set-TeamViewerRole -ApiToken $testApiToken -Name $testRoleName -Permissions $testPermissions -RoleId $testRoleId $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json $body.Permissions | Should -Be $testPermissions } - # It 'Should return a UserRole object' { + # It 'Should return a Role object' { #Request doesn't return a response body # } From a6bd8cb97da12255de4d9e42d9265feaa28394f3 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Fri, 20 Oct 2023 20:14:05 +0200 Subject: [PATCH 092/110] Fixes typo --- Docs/Help/Get-TeamViewerUserByRole.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Help/Get-TeamViewerUserByRole.md b/Docs/Help/Get-TeamViewerUserByRole.md index 0fae67a..cbdaaeb 100644 --- a/Docs/Help/Get-TeamViewerUserByRole.md +++ b/Docs/Help/Get-TeamViewerUserByRole.md @@ -29,7 +29,7 @@ Lists all users of role in the TeamViewer company associated with the API access PS /> Get-TeamViewerUserByRole -RoleId '72abbedc-9853-4fc8-9d28-fa35e207b048' ``` -Lists all users of the ole `72abbedc-9853-4fc8-9d28-fa35e207b048`. +Lists all users of the role `72abbedc-9853-4fc8-9d28-fa35e207b048`. ## PARAMETERS From 4726118d9fb80ad33f41d29e8a9f07c3e73489f4 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Fri, 20 Oct 2023 20:38:38 +0200 Subject: [PATCH 093/110] Fixing tests 2nd --- Docs/Help/Remove-TeamViewerPredefinedRole.md | 2 +- Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 | 2 +- Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 | 2 +- Tests/Public/Remove-TeamViewerRole.Tests.ps1 | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Docs/Help/Remove-TeamViewerPredefinedRole.md b/Docs/Help/Remove-TeamViewerPredefinedRole.md index e7c8f11..dc36c04 100644 --- a/Docs/Help/Remove-TeamViewerPredefinedRole.md +++ b/Docs/Help/Remove-TeamViewerPredefinedRole.md @@ -9,7 +9,7 @@ schema: 2.0.0 ## SYNOPSIS -Remove existing predefined role. +Sets the existing predefined role to a not predefined one. ## SYNTAX diff --git a/Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 b/Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 index 3b425e3..b3681e5 100644 --- a/Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserByRole.Tests.ps1 @@ -24,7 +24,7 @@ Describe 'Get-TeamViewerUserByRole' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/assignments/account?RoleId=$testRoleId" -And ` + $Uri -eq "//unit.test/userroles/assignments/account?userRoleId=$testRoleId" -And ` $Method -eq 'Get' } } diff --git a/Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 b/Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 index bdab9ae..9802e53 100644 --- a/Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUserGroupByRole.Tests.ps1 @@ -24,7 +24,7 @@ Describe 'Get-TeamViewerUserGroupByRole' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles/assignments/usergroups?RoleId=$testRoleId" -And ` + $Uri -eq "//unit.test/userroles/assignments/usergroups?userRoleId=$testRoleId" -And ` $Method -eq 'Get' } } diff --git a/Tests/Public/Remove-TeamViewerRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 index 3eb4e8f..bd52d8b 100644 --- a/Tests/Public/Remove-TeamViewerRole.Tests.ps1 +++ b/Tests/Public/Remove-TeamViewerRole.Tests.ps1 @@ -19,7 +19,7 @@ Describe 'Remove-TeamViewerRole' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles?RoleId=$testRoleId" -And ` + $Uri -eq "//unit.test/userroles?userRoleId=$testRoleId" -And ` $Method -eq 'Delete' } } @@ -30,7 +30,7 @@ Describe 'Remove-TeamViewerRole' { Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` - $Uri -eq "//unit.test/userroles?RoleId=$testRoleId" -And ` + $Uri -eq "//unit.test/userroles?userRoleId=$testRoleId" -And ` $Method -eq 'Delete' } } From 1bae49930d64cf36ba3661dbaa4fcf2f064b8183 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Sat, 21 Oct 2023 11:16:17 +0200 Subject: [PATCH 094/110] Fixes payload and vars in body --- Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 | 8 ++++---- Cmdlets/Public/Add-TeamViewerUserToRole.ps1 | 4 ++-- Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 | 4 ++-- Cmdlets/Public/Set-TeamViewerRole.ps1 | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 index 1328533..131b884 100644 --- a/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 +++ b/Cmdlets/Private/ConvertTo-TeamViewerPredefinedRole.ps1 @@ -5,11 +5,11 @@ function ConvertTo-TeamViewerPredefinedRole { $InputObject ) process { - if($InputObject){ - $properties = @{ - PredefinedRoleId = $InputObject.PredefinedRoleId + if ($InputObject) { + $properties = @{ + PredefinedRoleId = $InputObject.PredefinedUserRoleId + } } - } $result = New-Object -TypeName PSObject -Property $properties $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.PredefinedRole') diff --git a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 index f6fb2e1..60be9e6 100644 --- a/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserToRole.ps1 @@ -23,8 +23,8 @@ function Add-TeamViewerUserToRole { $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" $AccountsToAdd = @() $body = @{ - UserIds = @() - RoleId = $id + UserIds = @() + UserRoleId = $id } function Invoke-TeamViewerRestMethodInternal { $result = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 index 3f07a28..cbe2bbc 100644 --- a/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 +++ b/Cmdlets/Public/Remove-TeamViewerUserFromRole.ps1 @@ -23,8 +23,8 @@ function Remove-TeamViewerUserFromRole { $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" $AccountsToRemove = @() $body = @{ - UserIds = @() - RoleId = $id + UserIds = @() + UserRoleId = $id } function Invoke-TeamViewerRestMethodInternal { $result = Invoke-TeamViewerRestMethod ` diff --git a/Cmdlets/Public/Set-TeamViewerRole.ps1 b/Cmdlets/Public/Set-TeamViewerRole.ps1 index 4f740b9..ca76074 100644 --- a/Cmdlets/Public/Set-TeamViewerRole.ps1 +++ b/Cmdlets/Public/Set-TeamViewerRole.ps1 @@ -27,7 +27,7 @@ function Set-TeamViewerRole { $body = @{ Name = $Name Permissions = @() - RoleId = $RoleId + UserRoleId = $RoleId } if ($Permissions) { From 5094a71c959fd02a09c40a2f421598b522ec6f8d Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Sat, 21 Oct 2023 13:08:40 +0200 Subject: [PATCH 095/110] Fixes tests --- Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 | 8 ++++---- Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 | 6 ++---- ...omRole.Tests.ps1 => Remove-TeamViewerUserFromRole.ps1} | 0 3 files changed, 6 insertions(+), 8 deletions(-) rename Tests/Public/{Remove-TeamViewerAccountFromRole.Tests.ps1 => Remove-TeamViewerUserFromRole.ps1} (100%) diff --git a/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 b/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 index dcd0f0b..7ee4563 100644 --- a/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerUserToRole.Tests.ps1 @@ -14,8 +14,8 @@ BeforeAll { $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @{ - UserIds = @($testAccount) - RoleId = $testRoleId + UserIds = @($testAccount) + UserRoleId = $testRoleId } } } @@ -43,7 +43,7 @@ Describe 'Add-TeamViewerUserToRole' { foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.RoleId | Should -Be $testRoleId + $body.UserRoleId | Should -Be $testRoleId } It 'Should accept pipeline input' { @@ -56,6 +56,6 @@ Describe 'Add-TeamViewerUserToRole' { foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.RoleId | Should -Be $testRoleId + $body.UserRoleId | Should -Be $testRoleId } } diff --git a/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 b/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 index ac17da0..49645aa 100644 --- a/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerPredefinedRole.Tests.ps1 @@ -9,11 +9,10 @@ BeforeAll { Mock Get-TeamViewerApiUri { '//unit.test' } Mock Invoke-TeamViewerRestMethod { - @{ PredefinedRoleId = 'e1631449-6321-4a58-920c-5440029b092e' } + @{ PredefineduserRoleId = 'e1631449-6321-4a58-920c-5440029b092e' } } } - Describe 'Get-TeamViewerPredefinedRole' { It 'Should call the correct API endpoint to list PredefinedRole' { @@ -27,7 +26,7 @@ Describe 'Get-TeamViewerPredefinedRole' { It 'Should convert input object to TeamViewerPS.PrefinedRole' { $inputObject = @{ - PredefinedRoleId = 'a9c9435d-8544-4e6a-9830-9337078c9aab' + PredefineduserRoleId = 'a9c9435d-8544-4e6a-9830-9337078c9aab' } | ConvertTo-Json $result = $inputObject | ConvertFrom-Json | ConvertTo-TeamViewerPredefinedRole @@ -37,7 +36,6 @@ Describe 'Get-TeamViewerPredefinedRole' { $result.PredefinedRoleID | Should -Be 'a9c9435d-8544-4e6a-9830-9337078c9aab' } - It 'Should return PredefinedRole objects' { $result = Get-TeamViewerPredefinedRole -ApiToken $testApiToken $result | Should -HaveCount 1 diff --git a/Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 b/Tests/Public/Remove-TeamViewerUserFromRole.ps1 similarity index 100% rename from Tests/Public/Remove-TeamViewerAccountFromRole.Tests.ps1 rename to Tests/Public/Remove-TeamViewerUserFromRole.ps1 From dcf585327f30b5adf2dae71987cc02b9fcac0ea2 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Sun, 22 Oct 2023 15:13:35 +0200 Subject: [PATCH 096/110] Fixes UserRoleId --- Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 index 9b12ff7..88aea27 100644 --- a/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 +++ b/Cmdlets/Public/Add-TeamViewerUserGroupToRole.ps1 @@ -24,7 +24,7 @@ function Add-TeamViewerUserGroupToRole { $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ - RoleId = $RoleId + UserRoleId = $RoleId UserGroupId = $UserGroup } From 3dcbdf9bffc9ec2832d7bc0acf2bc38cb2fd11e5 Mon Sep 17 00:00:00 2001 From: Karthick Gandhi Date: Wed, 25 Oct 2023 14:52:38 +0200 Subject: [PATCH 097/110] New-Package.ps1 modified --- Build/New-Package.ps1 | 2 +- Cmdlets/TeamViewerPS.psd1 | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Build/New-Package.ps1 b/Build/New-Package.ps1 index 38c63f9..ceb2da3 100644 --- a/Build/New-Package.ps1 +++ b/Build/New-Package.ps1 @@ -40,7 +40,7 @@ Write-Verbose 'Creating module manifest...' Copy-Item -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.psd1') -Destination $Build_OutputPath Copy-Item -Path (Join-Path -Path $Repo_CmdletPath -ChildPath '*.format.ps1xml') -Destination $Build_OutputPath -Update-Metadata -Path (Join-Path -Path $Repo_CmdletPath -ChildPath 'TeamViewerPS.psd1') -PropertyName 'FunctionsToExport' -Value $PublicFunctions.BaseName +Update-Metadata -Path (Join-Path -Path $Build_OutputPath -ChildPath 'TeamViewerPS.psd1') -PropertyName 'FunctionsToExport' -Value $PublicFunctions.BaseName # Copy additional package files Write-Verbose 'Copying additional files into the package...' diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index 70615f4..d2e0437 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -60,8 +60,7 @@ # NestedModules = @() # Functions to export from this module. - FunctionsToExport = @('Add-TeamViewerAssignment', 'Add-TeamViewerCustomization', 'Add-TeamViewerManagedDevice', 'Add-TeamViewerManager', 'Add-TeamViewerUserToRole', 'Add-TeamViewerUserGroupToRole', 'Add-TeamViewerSsoExclusion', 'Add-TeamViewerUserGroupMember', 'Connect-TeamViewerApi', 'Disconnect-TeamViewerApi', 'Export-TeamViewerSystemInformation', 'Get-TeamViewerAccount', 'Get-TeamViewerConnectionReport', 'Get-TeamViewerContact', 'Get-TeamViewerCustomModuleId', 'Get-TeamViewerDevice', 'Get-TeamViewerEventLog', 'Get-TeamViewerGroup', 'Get-TeamViewerId', 'Get-TeamViewerInstallationDirectory', 'Get-TeamViewerLogFilePath', 'Get-TeamViewerManagedDevice', 'Get-TeamViewerManagedGroup', 'Get-TeamViewerManagementId', 'Get-TeamViewerManager', 'Get-TeamViewerPolicy', 'Get-TeamViewerPredefinedRole', 'Get-TeamViewerUserByRole', 'Get-TeamViewerUserGroupByRole', 'Get-TeamViewerService', 'Get-TeamViewerSsoDomain', 'Get-TeamViewerSsoExclusion', 'Get-TeamViewerUser', 'Get-TeamViewerUserGroup', 'Get-TeamViewerUserGroupMember', 'Get-TeamViewerRole', 'Get-TeamViewerVersion', 'Invoke-TeamViewerPackageDownload', 'Invoke-TeamViewerPing', 'New-TeamViewerContact', 'New-TeamViewerDevice', 'New-TeamViewerGroup', 'New-TeamViewerManagedGroup', 'New-TeamViewerPolicy', 'New-TeamViewerUser', 'New-TeamViewerUserGroup', 'New-TeamViewerRole', 'Publish-TeamViewerGroup', 'Remove-TeamViewerAssignment', 'Remove-TeamViewerContact', 'Remove-TeamViewerCustomization', 'Remove-TeamViewerDevice', 'Remove-TeamViewerGroup', 'Remove-TeamViewerManagedDevice', 'Remove-TeamViewerManagedDeviceManagement', 'Remove-TeamViewerManagedGroup', 'Remove-TeamViewerManager', 'Remove-TeamViewerPolicy', 'Remove-TeamViewerPolicyFromManagedDevice', 'Remove-TeamViewerPredefinedRole', 'Remove-TeamViewerPSProxy', 'Remove-TeamViewerUserFromRole', 'Remove-TeamViewerUserGroupFromRole', 'Remove-TeamViewerSsoExclusion', 'Remove-TeamViewerUser', 'Remove-TeamViewerUserGroup', 'Remove-TeamViewerUserGroupMember', 'Remove-TeamViewerRole', 'Restart-TeamViewerService', 'Set-TeamViewerAccount', 'Set-TeamViewerAPIUri', 'Set-TeamViewerDevice', 'Set-TeamViewerGroup', 'Set-TeamViewerManagedDevice', 'Set-TeamViewerManagedGroup', 'Set-TeamViewerManager', 'Set-TeamViewerPolicy', 'Set-TeamViewerPredefinedRole', 'Set-TeamViewerPSProxy', 'Set-TeamViewerUser', 'Set-TeamViewerUserGroup', 'Set-TeamViewerRole', 'Start-TeamViewerService', 'Stop-TeamViewerService', 'Test-TeamViewerConnectivity', 'Test-TeamViewerInstallation', 'Unpublish-TeamViewerGroup') - + FunctionsToExport = '*' # Cmdlets to export from this module. CmdletsToExport = @() From f75da9fcc0346a63583e2bc4c05aab88edfd4b25 Mon Sep 17 00:00:00 2001 From: Alexandros Alexiou Date: Thu, 26 Oct 2023 12:43:15 +0300 Subject: [PATCH 098/110] Add set/remove group policy functionality --- ...emove-TeamViewerPolicyFromManagedGroup.ps1 | 39 + .../Public/Set-TeamViewerManagedDevice.ps1 | 22 +- Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 | 60 +- Cmdlets/TeamViewerPS.psm1 | 5902 ++++++++++++++++- ...Remove-TeamViewerPolicyFromManagedGroup.md | 160 + Docs/Help/Set-TeamViewerManagedGroup.md | 47 + ...TeamViewerPolicyFromManagedGroup.Tests.ps1 | 54 + .../Set-TeamViewerManagedGroup.Tests.ps1 | 120 +- 8 files changed, 6369 insertions(+), 35 deletions(-) create mode 100644 Cmdlets/Public/Remove-TeamViewerPolicyFromManagedGroup.ps1 create mode 100644 Docs/Help/Remove-TeamViewerPolicyFromManagedGroup.md create mode 100644 Tests/Public/Remove-TeamViewerPolicyFromManagedGroup.Tests.ps1 diff --git a/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedGroup.ps1 b/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedGroup.ps1 new file mode 100644 index 0000000..fc73115 --- /dev/null +++ b/Cmdlets/Public/Remove-TeamViewerPolicyFromManagedGroup.ps1 @@ -0,0 +1,39 @@ +function Remove-TeamviewerPolicyFromManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias('GroupId')] + [object] + $Group, + + [Parameter(Mandatory = $true)] + [PolicyType] + $PolicyType + ) + Begin { + $body = @{ + 'policy_type' = [int]$PolicyType + } + } + Process { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/policy/remove" + + if ($PSCmdlet.ShouldProcess($Group.ToString(), 'Change managed group entry')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} diff --git a/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 b/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 index 4370385..d047331 100644 --- a/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 +++ b/Cmdlets/Public/Set-TeamViewerManagedDevice.ps1 @@ -7,21 +7,21 @@ function Set-TeamViewerManagedDevice { [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] + [Alias('DeviceId')] [object] $Device, - [Alias("Alias")] + [Alias('Alias')] [string] $Name, [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias("PolicyId")] + [Alias('PolicyId')] [object] $Policy, [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("ManagedGroupId")] + [Alias('ManagedGroupId')] [object] $ManagedGroup ) @@ -38,28 +38,28 @@ function Set-TeamViewerManagedDevice { $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId } - if ($Policy -And $ManagedGroup) { + if ($Policy -And $ManagedGroup) { $PSCmdlet.ThrowTerminatingError( - ("The combination of parameters -Policy and -ManagedGroup is not allowed." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + ('The combination of parameters -Policy and -ManagedGroup is not allowed.' | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } if ($body.Count -eq 0) { $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the managed device." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + ('The given input does not change the managed device.' | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } } Process { $deviceId = $Device | Resolve-TeamViewerManagedDeviceId $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" - if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { + if ($PSCmdlet.ShouldProcess($Device.ToString(), 'Change managed device entry')) { Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` -Method Put ` - -ContentType "application/json; charset=utf-8" ` + -ContentType 'application/json; charset=utf-8' ` -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` -WriteErrorTo $PSCmdlet ` -ErrorAction Stop | ` diff --git a/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 b/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 index 325ef10..52e434b 100644 --- a/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 +++ b/Cmdlets/Public/Set-TeamViewerManagedGroup.ps1 @@ -7,55 +7,87 @@ function Set-TeamViewerManagedGroup { [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias("GroupId")] - [Alias("Id")] + [Alias('GroupId')] + [Alias('Id')] [object] $Group, - [Parameter(Mandatory = $true, ParameterSetName = 'ByParameters')] + [Parameter(ParameterSetName = 'ByParameters')] [string] $Name, + [Parameter(ParameterSetName = 'ByParameters')] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('Policy')] + [object] + $PolicyId, + + [Parameter(ParameterSetName = 'ByParameters')] + [PolicyType] + $PolicyType, + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] [hashtable] $Property ) + Begin { - # Warning suppresion doesn't seem to work. + # Warning suppression doesn't seem to work. # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 $null = $Property $body = @{} switch ($PSCmdlet.ParameterSetName) { 'ByParameters' { - $body['name'] = $Name + if ($Name) { + $body['name'] = $Name + } + + if ($PolicyId -or $PolicyType) { + if (-not ($PolicyId -and $PolicyType)) { + $PSCmdlet.ThrowTerminatingError( + ('PolicyId and PolicyType must be specified together' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $body['policy'] = @{ + 'policy_id' = $PolicyId + 'policy_type' = $PolicyType + } + } } 'ByProperties' { - @('name') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } + @('name') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } + + if ($Property.ContainsKey('policy_id') -or $Property.ContainsKey('policy_type')) { + if (-not ($Property.ContainsKey('policy_id') -and $Property.ContainsKey('policy_type'))) { + $PSCmdlet.ThrowTerminatingError( + ('PolicyId and PolicyType must be specified together' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $body['policy'] = @{ + 'policy_id' = $Property['policy_id'] + 'policy_type' = [PolicyType]$Property['policy_type'] + } + } } } if ($body.Count -eq 0) { $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the managed group." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + ('The given input does not change the managed group.' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) } } + Process { $groupId = $Group | Resolve-TeamViewerManagedGroupId $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" - if ($PSCmdlet.ShouldProcess($groupId, "Update managed group")) { + if ($PSCmdlet.ShouldProcess($groupId, 'Update managed group')) { Invoke-TeamViewerRestMethod ` -ApiToken $ApiToken ` -Uri $resourceUri ` -Method Put ` - -ContentType "application/json; charset=utf-8" ` + -ContentType 'application/json; charset=utf-8' ` -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null + -WriteErrorTo $PSCmdlet | Out-Null } } } diff --git a/Cmdlets/TeamViewerPS.psm1 b/Cmdlets/TeamViewerPS.psm1 index d91058d..a431dc0 100644 --- a/Cmdlets/TeamViewerPS.psm1 +++ b/Cmdlets/TeamViewerPS.psm1 @@ -1,6 +1,5898 @@ -$ModuleTypes = @( Get-ChildItem -Path "$PSScriptRoot/TeamViewerPS.Types.ps1" -ErrorAction SilentlyContinue ) -$PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -ErrorAction SilentlyContinue ) -$PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -ErrorAction SilentlyContinue ) +enum TeamViewerConnectionReportSessionType { + RemoteConnection = 1 + RemoteSupportActive = 2 + RemoteSupportActiveSdk = 3 +} + +enum PolicyType { + TeamViewer = 1 + Monitoring = 4 + PatchManagement = 5 +} + + + +function Add-Registry { + param ( + [Microsoft.Win32.RegistryKey]$RegKey, + [string]$Program + ) + + #CustomObject including all information for each registry and sub keys + $retRegKey = [PSCustomObject]@{ + Program = $Program + RegistryPath = $RegKey.Name + Entries = @() + } + Write-Output "Collecting registry data $($retRegKey.RegistryPath)" + foreach ($valueName in $RegKey.GetValueNames()) { + $value = $RegKey.GetValue($valueName) + $type, $value = Get-TypeAndValueOfRegistryValue -RegKey $RegKey -ValueName $valueName + $blackList = @('BuddyLoginTokenAES', 'BuddyLoginTokenSecretAES', 'Certificate', 'CertificateKey', 'CertificateKeyProtected', + 'MultiPwdMgmtPwdData', 'PermanentPassword', 'PK', 'SecurityPasswordAES', 'SK', 'SRPPasswordMachineIdentifier') + foreach ($blackListValue in $blackList) { + if ($valueName -eq $blackListValue) { + $value = '___PRIVATE___' + } + } + $entry = [PSCustomObject]@{ + Name = $valueName + Value = $value + Type = $type + } + $retRegKey.Entries += $entry + } + + foreach ($subKeyName in $RegKey.GetSubKeyNames()) { + $subKey = $RegKey.OpenSubKey($subKeyName) + Add-Registry -RegKey $subKey -Program $subKeyName + } + #Adding CustomObject to array declared in Get-RegistryPaths + $AllTVRegistryData.Add($retRegKey) | Out-Null +} + + + + + +function ConvertTo-DateTime { + param( + [Parameter(ValueFromPipeline)] + [string] + $InputString + ) + + process { + try { + Write-Output ([DateTime]::Parse($InputString)) + } + catch { + Write-Output $null + } + } +} + + +function ConvertTo-ErrorRecord { + param( + [Parameter(ValueFromPipeline)] + [object] + $InputObject, + + [Parameter()] + [System.Management.Automation.ErrorCategory] + $ErrorCategory = [System.Management.Automation.ErrorCategory]::NotSpecified + ) + Process { + $category = $ErrorCategory + $message = $InputObject.ToString() + $errorId = 'TeamViewerError' + + if ($InputObject.PSObject.TypeNames -contains 'TeamViewerPS.RestError') { + $category = switch ($InputObject.ErrorCategory) { + 'invalid_request' { [System.Management.Automation.ErrorCategory]::InvalidArgument } + 'invalid_token' { [System.Management.Automation.ErrorCategory]::AuthenticationError } + 'internal_error' { [System.Management.Automation.ErrorCategory]::NotSpecified } + 'rate_limit_reached' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } + 'token_expired' { [System.Management.Automation.ErrorCategory]::AuthenticationError } + 'wrong_credentials' { [System.Management.Automation.ErrorCategory]::AuthenticationError } + 'invalid_client' { [System.Management.Automation.ErrorCategory]::InvalidArgument } + 'not_found' { [System.Management.Automation.ErrorCategory]::ObjectNotFound } + 'too_many_retries' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } + 'invalid_permission' { [System.Management.Automation.ErrorCategory]::PermissionDenied } + default { [System.Management.Automation.ErrorCategory]::NotSpecified } + } + $errorId = 'TeamViewerRestError' + } + + $exception = [System.Management.Automation.RuntimeException]($message) + $errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $category, $null + $errorRecord.ErrorDetails = $message + return $errorRecord + } +} + + + +function ConvertTo-TeamViewerAccount { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Name = $InputObject.name + Email = $InputObject.email + UserId = $InputObject.userid + CompanyName = $InputObject.company_name + IsEmailValidated = $InputObject.email_validated + EmailLanguage = $InputObject.email_language + } + if ($InputObject.email_language -And $InputObject.email_language -Ne 'auto') { + $properties["EmailLanguage"] = [System.Globalization.CultureInfo]($InputObject.email_language) + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Account') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name) <$($this.Email)>" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerAuditEvent { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Name = $InputObject.EventName + Type = $InputObject.EventType + Timestamp = $InputObject.Timestamp | ConvertTo-DateTime + Author = $InputObject.Author + AffectedItem = $InputObject.AffectedItem + EventDetails = $InputObject.EventDetails + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.AuditEvent') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "[$($this.Timestamp)] $($this.Name) ($($this.Type))" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerConnectionReport { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.id + UserId = $InputObject.userid + UserName = $InputObject.username + DeviceId = $InputObject.deviceid + DeviceName = $InputObject.devicename + GroupId = $InputObject.groupid + GroupName = $InputObject.groupname + SupportSessionType = [TeamViewerConnectionReportSessionType]$InputObject.support_session_type + StartDate = $InputObject.start_date | ConvertTo-DateTime + EndDate = $InputObject.end_date | ConvertTo-DateTime + SessionCode = $InputObject.session_code + Fee = $InputObject.fee + BillingState = $InputObject.billing_state + Currency = $InputObject.currency + Notes = $InputObject.notes + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ConnectionReport') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerContact { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.contact_id + UserId = $InputObject.user_id + GroupId = $InputObject.groupid + Name = $InputObject.name + Description = $InputObject.description + OnlineState = $InputObject.online_state + ProfilePictureUrl = $InputObject.profilepicture_url + SupportedFeatures = $InputObject.supported_features + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Contact') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerDevice { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $remoteControlId = $InputObject.remotecontrol_id | ` + Select-String -Pattern 'r(\d+)' | ` + ForEach-Object { $_.Matches.Groups[1].Value } + $properties = @{ + Id = $InputObject.device_id + TeamViewerId = $remoteControlId + GroupId = $InputObject.groupid + Name = $InputObject.alias + Description = $InputObject.description + OnlineState = $InputObject.online_state + IsAssignedToCurrentAccount = $InputObject.assigned_to + SupportedFeatures = $InputObject.supported_features + } + if ($InputObject.policy_id) { + $properties['PolicyId'] = $InputObject.policy_id + } + if ($InputObject.last_seen) { + $properties['LastSeenAt'] = [datetime]($InputObject.last_seen) + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Device') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.id + Name = $InputObject.name + Permissions = $InputObject.permissions + SharedWith = @($InputObject.shared_with | ConvertTo-TeamViewerGroupShare) + } + if ($InputObject.owner) { + $properties.Owner = [pscustomobject]@{ + UserId = $InputObject.owner.userid + Name = $InputObject.owner.name + } + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Group') + Write-Output $result + } +} + + +function ConvertTo-TeamViewerGroupShare { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + UserId = $InputObject.userid + Name = $InputObject.name + Permissions = $InputObject.permissions + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.GroupShare') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.UserId)" + } + Write-Output $result + } +} + + +function ConvertTo-TeamViewerManagedDevice { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [guid]$InputObject.id + Name = $InputObject.name + TeamViewerId = $InputObject.TeamViewerId + IsOnline = $InputObject.isOnline + } + + if ($InputObject.last_seen) { + $properties['LastSeenAt'] = Get-Date -Date $InputObject.last_seen + } + + if ($InputObject.teamviewerPolicyId) { + $properties["PolicyId"] = [guid]$InputObject.teamviewerPolicyId + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedDevice') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerManagedGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [guid]$InputObject.id + Name = $InputObject.name + } + if ($InputObject.policy_id) { + $properties["PolicyId"] = $InputObject.policy_id + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedGroup') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerManager { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject, + + [Parameter(Mandatory = $true, ParameterSetName = "GroupManager")] + [guid] + $GroupId, + + [Parameter(Mandatory = $true, ParameterSetName = "DeviceManager")] + [guid] + $DeviceId + ) + process { + $properties = @{ + Id = [guid]$InputObject.id + ManagerType = $InputObject.type + Name = $InputObject.name + Permissions = $InputObject.permissions + } + + switch ($InputObject.type) { + 'account' { + $properties.AccountId = $InputObject.accountId + } + 'company' { + $properties.CompanyId = $InputObject.companyId + } + } + + switch ($PsCmdlet.ParameterSetName) { + 'GroupManager' { + $properties.GroupId = $GroupId + } + 'DeviceManager' { + $properties.DeviceId = $DeviceId + } + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Manager') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerPolicy { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + + process { + $properties = @{ + Id = $InputObject.policy_id + Name = $InputObject.name + Settings = @( + $InputObject.settings | ForEach-Object { + @{ + Key = $_.key + Value = $_.value + Enforce = $_.enforce + } + } + ) + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Policy') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerRestError { + param( + [parameter(ValueFromPipeline)] + $InputError + ) + Process { + try { + $errorObject = ($InputError | Out-String | ConvertFrom-Json) + $result = [PSCustomObject]@{ + Message = $errorObject.error_description + ErrorCategory = $errorObject.error + ErrorCode = $errorObject.error_code + ErrorSignature = $errorObject.error_signature + } + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "$($this.Message) ($($this.ErrorCategory))" + } + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RestError') + return $result + } + catch { + return $InputError + } + } +} + + + +function ConvertTo-TeamViewerRoleAssignedUser { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{AssignedUsers = ($InputObject.trim('u'))} + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUser') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerRoleAssignedUserGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{AssignedGroups = ($InputObject)} + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUserGroup') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerSsoDomain { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = $InputObject.DomainId + Name = $InputObject.DomainName + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.SsoDomain') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" + } + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUser { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject, + + [Parameter()] + [ValidateSet('All', 'Minimal')] + $PropertiesToLoad = 'All' + ) + + process { + $properties = @{ + Id = $InputObject.id + Name = $InputObject.name + Email = $InputObject.email + } + + if ($PropertiesToLoad -Eq 'All') { + $properties += @{ + Active = $InputObject.active + LastAccessDate = $InputObject.last_access_date | ConvertTo-DateTime + } + + if ($InputObject.activated_license_id) { + $properties += @{ + ActivatedLicenseId = [guid]$InputObject.activated_license_id + ActivatedLicenseName = $InputObject.activated_license_name + ActivatedSubLicenseName = $InputObject.activated_subLicense_name + } + } + + if ($InputObject.activated_meeting_license_key) { + $properties += @{ + ActivatedMeetingLicenseId = [guid]$InputObject.activated_meeting_license_key + } + } + } + + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.User') + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "$($this.Name) <$($this.Email)>" + } + + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUserGroup { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + Id = [UInt64]$InputObject.id + Name = $InputObject.name + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroup') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUserGroupMember { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + AccountId = [int]$InputObject.accountId + Name = $InputObject.name + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroupMember') + Write-Output $result + } +} + + + +function ConvertTo-TeamViewerUserRole { + param( + [Parameter(ValueFromPipeline)] + [PSObject] + $InputObject + ) + process { + $properties = @{ + RoleName = $InputObject.Name + RoleID = $InputObject.Id + } + if ($InputObject.Permissions) { + foreach ($permission in $InputObject.Permissions.PSObject.Properties) { + $properties[$permission.Name] = $permission.Value + } + } + $result = New-Object -TypeName PSObject -Property $properties + $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserRole') + $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { + Write-Output "[$($this.RoleName)] [$($this.RoleID)] $($this.Permissions))" + } + Write-Output $result + } +} + + + + +function Get-ClientId { + if (Test-Path -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer') { + $mainKey = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' + $id = [int]$mainKey.ClientID + } + elseif (Test-Path -Path 'HKLM:\Software\TeamViewer') { + $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' + $id = [int]$mainKey.ClientID + } + return $id +} + + + +function Get-HostFile { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + process { + $regPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' + $regKey = Get-ItemProperty -Path $regPath + $hostsPath = Join-Path -Path $regKey.DataBasePath -ChildPath 'hosts' + $hostsFile = Get-Content -Path $hostsPath + $hostsFile | Out-File -FilePath "$OutputPath\Data\hosts.txt" + Write-Output "hosts file collected and saved to $OutputPath\Data\hosts.txt" + } +} + + + +function Get-InstalledSoftware { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $regUninstall = @{ + InstalledSoftware32 = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' + InstalledSoftware64 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' + } + } + Process { + foreach ($Name in $regUninstall.keys) { + $regKeys = $regUninstall[$Name] + $regKey = Get-ItemProperty -Path "$regKeys\*" + if ($null -ne $regKey) { + $subKeys = $regKey.PSChildName + if ($null -ne $subKeys) { + $installedPrograms = @() + foreach ($subKey in $subKeys) { + $tmpSubkey = Get-ItemProperty -Path "$regKeys\$subKey" + $programmName = $tmpSubkey.DisplayName + $displayVersion = $tmpSubkey.DisplayVersion + if ($null -ne $programmName) { + $tmpSoftwareData = "$programmName | $displayVersion" + $installedPrograms += $tmpSoftwareData + } + } + } + $installedPrograms | Sort-Object | Out-File -FilePath "$OutputPath\Data\$Name.txt" + Write-Output "$Name collected and saved to $OutputPath\Data\$Name.txt" + } + } + } +} + + + + + +function Get-IpConfig { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Process { + try { + ipconfig /all | Out-File -FilePath "$OutputPath\Data\ipconfig.txt" -Encoding utf8 + Write-Output "ipconfig data collected and saved to $OutputPath\Data\ipconfig.txt" + } + catch { + Write-Error "An error occurred while collecting ipconfig data: $_" + } + } +} + + + +function Get-MSInfo32 { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Process { + try { + Start-Process -FilePath msinfo32.exe -ArgumentList "/nfo $OutputPath\Data\msinfo32.nfo" -Wait + + Write-Output "msinfo data collected and saved to $OutputPath\Data\msinfo32.nfo" + } + catch { + Write-Error "An error occurred while collecting msinfo data: $_" + } + } +} + + + +function Get-NSLookUpData { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $Ipv4DnsServer = @($null, 'tv-ns1.teamviewer.com', 'tv-ns2.teamviewer.com', 'tv-ns3.teamviewer.com', + 'tv-ns4.teamviewer.com', 'tv-ns5.teamviewer.com', '8.8.8.8', '1.1.1.1') + $Ipv4DnsName = @( 'master1.teamviewer.com', 'router1.teamviewer.com', 'google.com', + 'login.teamviewer.com', 'www.teamviewer.com') + $output = $null + } + Process { + try { + foreach ($DnsName in $Ipv4DnsName ) { + foreach ($DnsServer in $Ipv4DnsServer) { + Write-Output "Collecting nslookup.exe information from $DnsName $DnsServer. This might take a while" + $output += "nslookup information for: $DnsName $DnsServer `r`n" + $arguments = "-debug ""$DnsName""" + if ($DnsServer) { + $arguments += " ""$DnsServer""" + } + $processInfo = New-Object System.Diagnostics.ProcessStartInfo + $processInfo.FileName = 'nslookup.exe' + $processInfo.Arguments = $arguments + $processInfo.WindowStyle = 'Hidden' + $processInfo.UseShellExecute = $false + $processInfo.RedirectStandardOutput = $true + + $process = [System.Diagnostics.Process]::Start($processInfo) + $output += $process.StandardOutput.ReadToEnd() + $process.WaitForExit(60000) + if (-not $process.HasExited) { + $process.Kill() + continue + } + $output += $process.StandardOutput.ReadToEnd() + } + } + $output | Out-File "$OutputPath\Data\nslookup.txt" + } + + catch { + Write-Error "Error collecting nslookup information: $_" + } + } +} + + + + + +function Get-OperatingSystem { + if ($IsLinux) { + return 'Linux' + } + if ($IsMacOS) { + return 'MacOS' + } + if ($IsWindows -Or $env:OS -match '^Windows') { + return 'Windows' + } +} + + + +function Get-RegistryPath { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + Begin { + $SearchProgramms = @('TeamViewer', 'Blizz', 'TeamViewerMeeting') + $RegistrySearchPathsLocalMachine = @('SOFTWARE\Wow6432Node', 'SOFTWARE') + $RegistrySearchPathsCurrentUser = @('SOFTWARE') + $AllTVRegistryData = New-Object System.Collections.ArrayList + } + + Process { + foreach ($searchProgramm in $SearchProgramms) { + foreach ($registrySearchPath in $RegistrySearchPathsLocalMachine) { + $regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$registrySearchPath\$searchProgramm", $false) + if ($regKey) { + Add-Registry -RegKey $regKey -Program $searchProgramm + } + } + + foreach ($registrySearchPath in $RegistrySearchPathsCurrentUser) { + $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm", $false) + if ($searchProgramm -eq 'Blizz' -or $searchProgramm -eq 'TeamViewerMeeting') { + $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm\MachineFallback", $false) + } + if ($regKey) { + Add-Registry -RegKey $regKey -Program $searchProgramm + } + } + + $output = "Windows Registry Editor Version 5.00 `r`n" + foreach ($data in $AllTVRegistryData) { + $output += "[$($data.RegistryPath)]`r`n" + foreach ($entry in $data.Entries) { + if ($null -ne $entry.name) { + $output += """$($entry.Name)""" + $entry.Type + $entry.Value + "`r`n" + } + } + $output += "`r`n" + } + $output | Out-File -FilePath "$OutputPath\Data\TeamViewer_Version15\Reg_Version15.txt" + } + } + +} + + + +function Get-RouteTable { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) +Process{ + try { + $processInfo = New-Object System.Diagnostics.ProcessStartInfo + $processInfo.FileName = 'route.exe' + $processInfo.Arguments = 'print' + $processInfo.WindowStyle = 'Hidden' + $processInfo.UseShellExecute = $false + $processInfo.RedirectStandardOutput = $true + + $process = [System.Diagnostics.Process]::Start($processInfo) + $output = $process.StandardOutput.ReadToEnd() + $output | Out-File "$OutputPath\Data\RouteTable.txt" + } + catch { + Write-Error "An error occurred while collecting RouteTable data: $_" + } +} +} + + + + + +class TeamViewerConfiguration { + [string]$APIUri = 'https://webapi.teamviewer.com/api/v1' + + static [TeamViewerConfiguration] $Instance = $null + + static [TeamViewerConfiguration] GetInstance() { + if (-not [TeamViewerConfiguration]::Instance) { + [TeamViewerConfiguration]::Instance = [TeamViewerConfiguration]::new() + } + + return [TeamViewerConfiguration]::Instance + } +} + +function Get-TeamViewerAPIUri { + $config = [TeamViewerConfiguration]::GetInstance() + return $config.APIUri +} + + + + + +function Get-TeamViewerLinuxGlobalConfig { + param( + [Parameter()] + [string] + $Path = '/opt/teamviewer/config/global.conf', + + [Parameter()] + [string] + $Name + ) + $config = & sudo pwsh -command Get-Content $Path | ForEach-Object { + if ($_ -Match '\[(?\w+)\s*\]\s+(?[\w\\]+)\s+=\s*(?.*)$') { + $Matches.Remove(0) + $entry = [pscustomobject]$Matches + switch ($entry.EntryType) { + 'strng' { + $entry.EntryValue = $entry.EntryValue | ` + Select-String -Pattern '"([^\"]*)"' -AllMatches | ` + Select-Object -ExpandProperty Matches | ` + ForEach-Object { $_.Groups[1].Value } + } + 'int32' { + $entry.EntryValue = [int32]($entry.EntryValue) + } + 'int64' { + #In some cases the EntryName DeviceManagement/TransitionNonces is set to entryvalue '0 0 0 0 0' of type int64 + if ($entry.EntryValue -notmatch '0 0 0 0 0') { + $entry.EntryValue = [int64]($entry.EntryValue) + } + } + } + $entry + } + } + + if ($Name) { + ($config | Where-Object { $_.EntryName -eq $Name }).EntryValue + } + else { + $config + } +} + + + +function Get-TeamViewerRegKeyPath { + param ( + [Parameter()] + [ValidateSet('WOW6432', 'Auto')] + [string] + $Variant = 'Auto' + ) + if (($Variant -eq 'WOW6432') -Or (Test-TeamViewer32on64)) { + Write-Output 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' + } + else { + Write-Output 'HKLM:\SOFTWARE\TeamViewer' + } +} + + + +function Get-TeamViewerServiceName { + Write-Output 'TeamViewer' +} + + + +function Get-TSCDirectoryFile { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $OutputPath + ) + + Process { + $SearchDirectories = Get-TSCSearchDirectory + $TempDirectory = New-Item -Path $OutputPath -Name 'Data' -ItemType Directory -Force + $Endings = @('.log', 'tvinfo.ini', '.mdmp', 'Connections.txt', 'Connections_incoming.txt') + $TmpLogFiles = @() + foreach ($Name in $SearchDirectories.Keys) { + $SearchDirectory = $SearchDirectories[$Name] + foreach ($Folder in $SearchDirectory) { + if (Test-Path -Path $Folder) { + $TempSubdirectory = Join-Path -Path $TempDirectory -ChildPath $Name + New-Item -Path $TempSubdirectory -ItemType Directory -Force | Out-Null + $files = Get-ChildItem -Path $Folder -File -Recurse + foreach ($file in $files) { + foreach ($ending in $Endings) { + if ($file.Name.EndsWith($ending)) { + $tmpLogfilePath = Join-Path -Path $TempSubdirectory -ChildPath $file.Name + Copy-Item -Path $file.FullName -Destination $tmpLogfilePath -Force + $TmpLogFiles += $tmpLogfilePath + Write-Output "Collected log file from $($file.FullName)" + } + } + } + } + } + } + Write-Output 'Files from TeamViewer directories have been collected.' + } +} + + + +function Get-TSCSearchDirectory { + $LocalAppData = [System.Environment]::GetFolderPath('LocalApplicationData') + $RoamingAppData = [System.Environment]::GetFolderPath('ApplicationData') + $TVAppData = Join-Path -Path $LocalAppData.ToString() -ChildPath 'TeamViewer/Logs' + $TVRoamingData = Join-Path -Path $RoamingAppData.ToString() -ChildPath 'TeamViewer' + $InstallationDirectory = Get-TeamViewerInstallationDirectory + + $TSCSearchDirectory = @{ + 'TeamViewer_Version15' = $InstallationDirectory + 'AppData\TeamViewer' = @($TVAppData; $TVRoamingData) + } + + return $TSCSearchDirectory +} + + + +function Get-TypeAndValueOfRegistryValue { + param ( + [Microsoft.Win32.RegistryKey]$RegKey, + [string]$ValueName + ) + + $valueKind = $RegKey.GetValueKind($ValueName) + $type = $valueKind + + if ($valueKind -eq 'DWord') { + $type = "=dword:" + $value = [Convert]::ToInt32($RegKey.GetValue($ValueName)).ToString('x') + } + elseif ($valueKind -eq 'Binary') { + $type = "=hex:" + $value = ($RegKey.GetValue($ValueName) | ForEach-Object { $_.ToString('x2') }) -join ',' + } + elseif ($valueKind -eq 'String') { + $type = "=" + $value = $RegKey.GetValue($ValueName).ToString() + } + elseif ($valueKind -eq 'MultiString') { + $type = "=hex(7):" + $value += ($RegKey.GetValue($ValueName) | ForEach-Object { + $_.ToCharArray() | ForEach-Object { [Convert]::ToInt32($_).ToString('X') + ',00' } + }) -join ',' + $value += ',00,00,' + if ($value.Length -gt 0) { + $value += '00,00' + } + } + else { + $type = "" + $value = $RegKey.GetValue($ValueName).ToString() + } + + return $type, $value +} + + + + +function Invoke-ExternalCommand { + param( + [Parameter(Mandatory = $true, Position = 0)] + [string] + $Command, + + [Parameter(ValueFromRemainingArguments = $true)] + [object[]] + $CommandArgs + ) + & $Command @CommandArgs +} + + + +function Invoke-TeamViewerRestMethod { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [uri] + $Uri, + + [Microsoft.PowerShell.Commands.WebRequestMethod] + $Method, + + [System.Collections.IDictionary] + $Headers, + + [System.Object] + $Body, + + [string] + $ContentType, + + [System.Management.Automation.PSCmdlet] + $WriteErrorTo + + ) + + if (-Not $Headers) { + $Headers = @{ } + $PSBoundParameters.Add('Headers', $Headers) | Out-Null + } + + if ($global:TeamViewerProxyUriSet) { + $Proxy = $global:TeamViewerProxyUriSet + } + elseif ([Environment]::GetEnvironmentVariable('TeamViewerProxyUri') ) { + $Proxy = [Environment]::GetEnvironmentVariable('TeamViewerProxyUri') + if ($global:TeamViewerProxyUriRemoved) { + $Proxy = $null + } + } + If ($Proxy) { + $PSBoundParameters.Add('Proxy', $Proxy) | Out-Null + } + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ApiToken) + $Headers['Authorization'] = "Bearer $([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr))" + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + $PSBoundParameters.Remove('ApiToken') | Out-Null + $PSBoundParameters.Remove('WriteErrorTo') | Out-Null + + $currentTlsSettings = [Net.ServicePointManager]::SecurityProtocol + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + + $currentProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + + + # Using `Invoke-WebRequest` instead of `Invoke-RestMethod`: + # There is a known issue for PUT and DELETE operations to hang on Windows Server 2012. + try { + + return ((Invoke-WebRequest -UseBasicParsing @PSBoundParameters).Content | ConvertFrom-Json) + } + catch { + $msg = $null + if ($PSVersionTable.PSVersion.Major -ge 6) { + $msg = $_.ErrorDetails.Message + } + elseif ($_.Exception.Response) { + $stream = $_.Exception.Response.GetResponseStream() + $reader = New-Object System.IO.StreamReader($stream) + $reader.BaseStream.Position = 0 + $msg = $reader.ReadToEnd() + } + $err = ($msg | ConvertTo-TeamViewerRestError) + if ($WriteErrorTo) { + $WriteErrorTo.WriteError(($err | ConvertTo-ErrorRecord)) + } + else { + throw $err + } + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $currentTlsSettings + $ProgressPreference = $currentProgressPreference + } +} + + + +function Resolve-AssignmentErrorCode { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $exitCode + ) + Begin { + $exitCodeMessages = @{ + 0 = 'Operation successful' + 1 = 'Misspelled or used a wrong command' + 2 = 'Signature verification error' + 3 = 'TeamViewer is not installed' + 4 = 'The assignment configuration could not be verified against the TeamViewer Cloud.Try again later.' + 400 = 'Invalid assignment ID' + 401 = 'TeamViewer service not running' + 402 = 'Service Incompatible Version' + 403 = 'Check your internet connection' + 404 = 'Another assignment process running' + 405 = 'Timeout' + 406 = 'Failed due to unknown reasons' + 407 = 'Access denied. Ensure local administrator rights' + 408 = 'Denied by policy' + } + } + Process { + if ($exitCode) { + if ($exitCodeMessages.ContainsKey($exitCode)) { + Write-Output $exitCodeMessages[$exitCode] + } + else { + Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" + } + } + elseif ($exitCode -eq 0) { + Write-Output $exitCodeMessages[$exitCode] + } + } +} + + + +function Resolve-CustomizationErrorCode { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $exitCode + ) + Begin { + $exitCodeMessages = @{ + 0 = 'Operation successful' + 1 = 'Invalid command line arguments' + 500 = 'An internal error occurred. See TeamViewer log files for more details!' + 501 = 'The current user was denied access' + 502 = 'The download of the custom configuration timed out' + 503 = 'Invalid Module' + 504 = 'Restart of the GUI failed' + 505 = 'Custom configuration failed. See the TeamViewer log files for more details and check if the custom configuration id is still valid.' + 506 = 'Removal of custom configuration failed. See the TeamViewer log files for more details!' + } + } + Process { + if ($exitCode) { + if ($exitCodeMessages.ContainsKey($exitCode)) { + Write-Output $exitCodeMessages[$exitCode] + } + else { + Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" + } + } + elseif ($exitCode -eq 0) { + Write-Output $exitCodeMessages[$exitCode] + } + } +} + + + +function Resolve-TeamViewerContactId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Contact + ) + Process { + if ($Contact.PSObject.TypeNames -contains 'TeamViewerPS.Contact') { + return $Contact.Id + } + elseif ($Contact -is [string]) { + if ($Contact -notmatch 'c[0-9]+') { + throw "Invalid contact identifier '$Contact'. String must be a contact ID in the form 'c123456789'." + } + return $Contact + } + else { + throw "Invalid contact identifier '$Contact'. Must be either a [TeamViewerPS.Contact] or [string]." + } + } +} + + + +function Resolve-TeamViewerDeviceId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Device + ) + Process { + if ($Device.PSObject.TypeNames -contains 'TeamViewerPS.Device') { + return $Device.Id + } + elseif ($Device -is [string]) { + if ($Device -notmatch 'd[0-9]+') { + throw "Invalid device identifier '$Device'. String must be a device ID in the form 'd123456789'." + } + return $Device + } + else { + throw "Invalid device identifier '$Device'. Must be either a [TeamViewerPS.Device] or [string]." + } + } +} + + + +function Resolve-TeamViewerGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Group + ) + Process { + if ($Group.PSObject.TypeNames -contains 'TeamViewerPS.Group') { + return $Group.Id + } + elseif ($Group -is [string]) { + if ($Group -notmatch 'g[0-9]+') { + throw "Invalid group identifier '$Group'. String must be a group ID in the form 'g123456789'." + } + return $Group + } + else { + throw "Invalid group identifier '$Group'. Must be either a [TeamViewerPS.Group] or [string]." + } + } +} + + + +function Resolve-TeamViewerLanguage { + param( + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [object] + $InputObject + ) + Process { + $supportedLanguages = @( + 'bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'hr', 'hu', 'id', 'it', 'ja', + 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'th', 'tr', 'uk', + 'vi', 'zh_CN', 'zh_TW', 'auto') + + $language = $InputObject + if ($InputObject -is [cultureinfo]) { + $language = switch ($InputObject.Name) { + 'zh-CN' { 'zh_CN' } + 'zh-TW' { 'zh_TW' } + default { $InputObject.TwoLetterISOLanguageName } + } + } + + if ($supportedLanguages -notcontains $language) { + throw "Invalid culture '$language'. Supported languages are: $supportedLanguages" + } + + return $language + } +} + + + +function Resolve-TeamViewerManagedDeviceId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $ManagedDevice + ) + Process { + if ($ManagedDevice.PSObject.TypeNames -contains 'TeamViewerPS.ManagedDevice') { + return [guid]$ManagedDevice.Id + } + elseif ($ManagedDevice -is [string]) { + return [guid]$ManagedDevice + } + elseif ($ManagedDevice -is [guid]) { + return $ManagedDevice + } + else { + throw "Invalid managed device identifier '$ManagedDevice'. Must be either a [TeamViewerPS.ManagedDevice], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerManagedGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $ManagedGroup + ) + Process { + if ($ManagedGroup.PSObject.TypeNames -contains 'TeamViewerPS.ManagedGroup') { + return [guid]$ManagedGroup.Id + } + elseif ($ManagedGroup -is [string]) { + return [guid]$ManagedGroup + } + elseif ($ManagedGroup -is [guid]) { + return $ManagedGroup + } + else { + throw "Invalid managed group identifier '$ManagedGroup'. Must be either a [TeamViewerPS.ManagedGroup], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerManagerId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Manager + ) + Process { + if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { + return [guid]$Manager.Id + } + elseif ($Manager -is [string]) { + return [guid]$Manager + } + elseif ($Manager -is [guid]) { + return $Manager + } + else { + throw "Invalid manager identifier '$Manager'. Must be either a [TeamViewerPS.Manager], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerPolicyId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Policy, + + [Parameter()] + [switch] + $AllowNone, + + [Parameter()] + [switch] + $AllowInherit + ) + Process { + if ($Policy.PSObject.TypeNames -contains 'TeamViewerPS.Policy') { + return [guid]$Policy.Id + } + elseif ($Policy -is [string]) { + if ($Policy -eq 'none' -And $AllowNone) { + return 'none' + } + elseif ($Policy -eq 'inherit' -And $AllowInherit) { + return 'inherit' + } + else { + return [guid]$Policy + } + } + elseif ($Policy -is [guid]) { + return $Policy + } + else { + throw "Invalid policy identifier '$Policy'. Must be either a [TeamViewerPS.Policy], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerSsoDomainId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $Domain + ) + Process { + if ($Domain.PSObject.TypeNames -contains 'TeamViewerPS.SsoDomain') { + return [guid]$Domain.Id + } + elseif ($Domain -is [string]) { + return [guid]$Domain + } + elseif ($Domain -is [guid]) { + return $Domain + } + else { + throw "Invalid SSO domain identifier '$Domain'. Must be either a [TeamViewerPS.SsoDomain], [guid] or [string]." + } + } +} + + + +function Resolve-TeamViewerUserEmail { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $false)] + [object] + $User + ) + Process { + if (!$User) { + return $null + } + elseif ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { + return $User.Email + } + elseif ($User -is [string]) { + return $User + } + else { + throw "Invalid user email '$User'. Must be either a [TeamViewerPS.User] or [string]." + } + } +} + + + +function Resolve-TeamViewerUserGroupId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserGroup + ) + Process { + if ($UserGroup.PSObject.TypeNames -contains 'TeamViewerPS.UserGroup') { + return [UInt64]$UserGroup.Id + } + elseif ($UserGroup -is [string]) { + return [UInt64]$UserGroup + } + elseif ($UserGroup -is [UInt64] -or $UserGroup -is [Int64] -or $UserGroup -is [int]) { + return [UInt64]$UserGroup + } + else { + throw "Invalid user group identifier '$UserGroup'. Must be either a [TeamViewerPS.UserGroup], [UInt64], [Int64] or [string]." + } + } +} + + + +function Resolve-TeamViewerUserGroupMemberMemberId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserGroupMember + ) + Process { + if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { + return $UserGroupMember.AccountId + } + elseif ($UserGroupMember -match 'u[0-9]+') { + return $UserGroupMember + } + elseif ($UserGroupMember -is [string]) { + return [int]$UserGroupMember + } + elseif ($UserGroupMember -is [int]) { + return $UserGroupMember + } + else { + throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." + } + } +} + + + +function Resolve-TeamViewerUserId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $User + ) + Process { + if ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { + return $User.Id + } + elseif ($User -is [string]) { + if ($User -notmatch 'u[0-9]+') { + throw "Invalid user identifier '$User'. String must be a user ID in the form 'u123456789'." + } + return $User + } + else { + throw "Invalid user identifier '$User'. Must be either a [TeamViewerPS.User] or [string]." + } + } +} + + + + +function Resolve-TeamViewerUserRoleId { + param( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [object] + $UserRole + ) + Process { + if ($UserRole.PSObject.TypeNames -contains 'TeamViewerPS.UserRole') { + return [string]$UserRole.RoleID + } + elseif ($UserRole -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { + return [string]$UserRole + } + else { + throw "Invalid role group identifier '$UserRole'. Must be either a [TeamViewerPS.UserRole] or [UUID] " + } + } +} + + + +$hasTestNetConnection = [bool](Get-Command Test-NetConnection -ErrorAction SilentlyContinue) +$hasTestConnection = [bool](Get-Command Test-Connection -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge 5.1 }) + +function Test-TcpConnection { + param( + [Parameter(Mandatory = $true)] + [string] + $Hostname, + + [Parameter(Mandatory = $true)] + [int] + $Port + ) + + if (-Not $hasTestNetConnection -And -Not $hasTestConnection) { + throw "No suitable cmdlet found for testing the TeamViewer network connectivity." + } + + $oldProgressPreference = $global:ProgressPreference + $global:ProgressPreference = 'SilentlyContinue' + + if ($hasTestNetConnection) { + Test-NetConnection -ComputerName $Hostname -Port $Port -InformationLevel Quiet -WarningAction SilentlyContinue + } + elseif ($hasTestConnection) { + Test-Connection -TargetName $Hostname -TcpPort $Port -Quiet -WarningAction SilentlyContinue + } + else { + $false + } + + $global:ProgressPreference = $oldProgressPreference +} + + + +function Test-TeamViewer32on64 { + if (![Environment]::Is64BitOperatingSystem) { + return $false + } + $registryKey = Get-TeamViewerRegKeyPath -Variant WOW6432 + if (!(Test-Path $registryKey)) { + return $false + } + try { + $installationDirectory = (Get-Item $registryKey).GetValue('InstallationDirectory') + $binaryPath = Join-Path $installationDirectory 'TeamViewer.exe' + return Test-Path $binaryPath + } + catch { + return $false + } +} + + + +function Add-TeamViewerAssignment { + param( + [Parameter(Mandatory = $true)] + [object] + $AssignmentId, + + [string] + $DeviceAlias, + + [int] + $Retries + ) + + + if (Test-TeamViewerInstallation) { + $OS = Get-OperatingSystem + $CurrentDirectory = Get-Location + $installationDirectory = Get-TeamViewerInstallationDirectory + Set-Location $installationDirectory + $CurrentVersion = Get-TeamViewerVersion + $VersionTable = $CurrentVersion.split('.') + if ($OS -eq 'Windows') { + $cmd = "assignment --id $AssignmentId" + $FilePath = 'TeamViewer.exe' + } + elseif ($OS -eq 'Linux') { + $cmd = "teamviewer assignment --id $AssignmentId" + $FilePath = 'sudo' + } + + if ($DeviceAlias) { + if (($VersionTable[0] -eq 15 -and $VersionTable[1] -ge 44) -or $VersionTable[0] -gt 15) { + $cmd += " --device-alias=$DeviceAlias" + } + else { + Write-Error "Current TeamViewer Version: $CurrentVersion does not support the usage of alias. Please update to the latest version." + Set-Location $CurrentDirectory + exit + } + } + if ($Retries) { + $cmd += " --retries=$Retries" + } + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } + else { + Write-Output 'TeamViewer is not installed.' + } +} + + + + + +Function Add-TeamViewerCustomization { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true, ParameterSetName = 'ById')] + [object] + $Id, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByPath')] + [object] + $Path, + + [switch] + $RestartGUI, + + [switch] + $RemoveExisting + ) + + if (Get-OperatingSystem -eq 'Windows') { + if (Test-TeamViewerInstallation) { + $installationDirectory = Get-TeamViewerInstallationDirectory + $currentDirectory = Get-Location + Set-Location $installationDirectory + $cmd = 'customize' + if ($Id) { + $cmd += " --id $Id" + } + elseif ($Path) { + $cmd += " --path $Path" + } + if ($RemoveExisting) { + $cmd += ' --remove' + } + if ($RestartGUI) { + $cmd += ' --restart-gui' + } + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + Set-Location $currentDirectory + } + else { + Write-Error 'TeamViewer is not installed' + } + } + else { + Write-Error 'Customization is currently supported only on Windows.' + } +} + + + +function Add-TeamViewerManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices" + + $body = @{ + id = $deviceId + } + + if ($PSCmdlet.ShouldProcess($deviceId, "Add device to managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Add-TeamViewerManager { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByAccountId')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] + [string] + $AccountId, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagerId } )] + [Alias("ManagerId")] + [object] + $Manager, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [object] + $User, + + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId })] + [Alias('UserGroupId')] + [object] + $UserGroup, + + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter()] + [AllowEmptyCollection()] + [string[]] + $Permissions + ) + + $resourceUri = $null + switch -Wildcard ($PSCmdlet.ParameterSetName) { + 'Device*' { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" + $processMessage = "Add manager to managed device" + } + 'Group*' { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" + $processMessage = "Add manager to managed group" + } + } + + $body = @{} + switch -Wildcard ($PSCmdlet.ParameterSetName) { + '*ByAccountId' { + $body["accountId"] = $AccountId.TrimStart('u') + } + '*ByManagerId' { + $body["id"] = $Manager | Resolve-TeamViewerManagerId + } + '*ByUserObject' { + $body["accountId"] = ( $User | Resolve-TeamViewerUserId ).TrimStart('u') + } + '*ByUserGroupId' { + $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId + } + } + + if ($Permissions) { + $body["permissions"] = @($Permissions) + } + else { + $body["permissions"] = @() + } + + if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @($body)))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Add-TeamViewerRoleToAccount { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias('Id', 'UserIds')] + [string[]] + $Accounts + ) + + Begin { + $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" + $AccountsToAdd = @() + $body = @{ + UserIds = @() + UserRoleId = $id + } + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($Accounts, 'Assign Account to Role')) { + if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { + $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } + } + foreach ($Account in $Accounts) { + $AccountsToAdd += $Account + $body.UserIds = @($AccountsToAdd) + } + } + if ($AccountsToAdd.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $AccountsToAdd = @() + } + } + End { + if ($AccountsToAdd.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + + +function Add-TeamViewerRoleToUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRoleId')] + [object] + $UserRole, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup + ) + + Begin { + $RoleId = $UserRole | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" + $body = @{ + UserRoleId = $RoleId + UserGroupId = $UserGroup + + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($UserGroup, 'Assign Role to User Group')) { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } +} + + + +function Add-TeamViewerSsoExclusion { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [string[]] + $Email + ) + Begin { + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" + $emailsToAdd = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-RequestInternal { + $body = @{ + emails = @($emailsToAdd) + } + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } + Process { + if ($PSCmdlet.ShouldProcess($Email, "Add SSO exclusion")) { + $emailsToAdd += $Email + } + if ($emailsToAdd.Length -eq 100) { + Invoke-RequestInternal + $emailsToAdd = @() + } + } + End { + if ($emailsToAdd.Length -gt 0) { + Invoke-RequestInternal + } + } +} + + + +function Add-TeamViewerUserGroupMember { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [object[]] + [Alias('UserGroupMemberId')] + [Alias('UserGroupMember')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] + $Member + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToAdd = @() + $body = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) + } + } + + Process { + # when members are provided as pipeline input, each member is provided as a separate statement, + # thus the members should be combined into one array in order to send a single request. + if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { + if ($Member -notmatch 'u[0-9]+') { + ForEach-Object { + $Member = [int[]]$Member + } + } + else { + ForEach-Object { + $Member = [int[]]$Member.trim('u') + } + } + if ($Member -isnot [array]) { + $membersToAdd = @([UInt32]$Member) + } + else { + $membersToAdd += [UInt32[]]$Member + } + $payload = $membersToAdd -join ', ' + $body = "[$payload]" + } + + # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` + # in order to accept more members + if ($membersToAdd.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $membersToAdd = @() + } + } + + End { + # A request needs to be sent if there were less than 100 members + if ($membersToAdd.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + +function Connect-TeamViewerApi { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + if (Invoke-TeamViewerPing -ApiToken $ApiToken) { + $global:PSDefaultParameterValues["*-Teamviewer*:ApiToken"] = $ApiToken + } +} + + +function Disconnect-TeamViewerApi { + $global:PSDefaultParameterValues.Remove("*-Teamviewer*:ApiToken") +} + + +function Export-TeamViewerSystemInformation { + param( + [Parameter(ValueFromPipeline = $true)] + [string] + $TargetDirectory + ) + Process { + if (Test-TeamViewerInstallation ) { + if (Get-OperatingSystem -eq 'Windows') { + $Temp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.Guid]::NewGuid().ToString()) + $CurrentDirectory = Get-Location + $Temp | Get-TSCDirectoryFile + $Temp | Get-InstalledSoftware + $Temp | Get-IpConfig + $Temp | Get-MSInfo32 + $Temp | Get-HostFile + $Temp | Get-NSLookUpData + $Temp | Get-RouteTable + $Temp | Get-RegistryPath + $ClientID = Get-ClientId + $ZipFileName = 'TV_SC_' + $ClientID + '_WINPS.zip' + $ZipPath = Join-Path -Path "$Temp\Data" -ChildPath $ZipFileName + Compress-Archive -Path $Temp\* -DestinationPath $ZipPath -Force + if ($TargetDirectory -and (Test-Path $TargetDirectory)) { + Copy-Item -Path $ZipPath -Destination $TargetDirectory -Force + } + else { + Copy-Item -Path $ZipPath -Destination $CurrentDirectory -Force + } + } + else { + Write-Error 'Currently this functionality is supported only on Windows.' + } + } + else { + Write-Error 'TeamViewer is not installed.' + } + } +} + + + +function Get-TeamViewerAccount { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/account" + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerAccount) +} + + + +function Get-TeamViewerConnectionReport { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $false)] + [string] + $UserName, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("User")] + [object] + $UserId, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("Group")] + [object] + $GroupId, + + [Parameter(Mandatory = $false)] + [string] + $DeviceName, + + [Parameter(Mandatory = $false)] + [int] + $DeviceId, + + [Parameter(Mandatory = $false)] + [switch] + $WithSessionCode, + + [Parameter(Mandatory = $false)] + [switch] + $WithoutSessionCode, + + [Parameter(Mandatory = $false)] + [string] + $SessionCode, + + [Parameter(Mandatory = $false)] + [TeamViewerConnectionReportSessionType] + $SupportSessionType, + + [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] + [DateTime] + $StartDate, + + [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [DateTime] + $EndDate = (Get-Date), + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 12)] + [int] + $Months, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 31)] + [int] + $Days, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 24)] + [int] + $Hours, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 60)] + [int] + $Minutes, + + [Parameter(Mandatory = $false)] + [ValidateRange(1, [int]::MaxValue)] + [int] + $Limit + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/reports/connections"; + + $parameters = @{} + + if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { + $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) + } + if ($StartDate -And $EndDate -And $StartDate -lt $EndDate) { + $parameters.from_date = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + $parameters.to_date = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + } + + if ($UserName) { + $parameters.username = $UserName + } + + if ($UserId) { + $parameters.userid = $UserId | Resolve-TeamViewerUserId + } + + if ($DeviceName) { + $parameters.devicename = $DeviceName + } + + if ($DeviceId) { + $parameters.deviceid = $DeviceId + } + + if ($GroupId) { + $parameters.groupid = $GroupId | Resolve-TeamViewerGroupId + } + + if ($WithSessionCode -And !$WithoutSessionCode) { + $parameters.has_code = $true + } + elseif ($WithoutSessionCode -And !$WithSessionCode) { + $parameters.has_code = $false + } + + if ($SessionCode) { + $parameters.session_code = $SessionCode + } + + if ($SupportSessionType) { + $parameters.support_session_type = [int]$SupportSessionType + } + + $remaining = $Limit + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $results = ($response.records | ConvertTo-TeamViewerConnectionReport) + if ($Limit) { + Write-Output ($results | Select-Object -First $remaining) + $remaining = $remaining - @($results).Count + } + else { + Write-Output $results + } + $parameters.offset_id = $response.next_offset + } while ($parameters.offset_id -And (!$Limit -Or $remaining -gt 0)) +} + + + +function Get-TeamViewerContact { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByContactId")] + [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] + [Alias("ContactId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [Alias("PartialName")] + [string] + $Name, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateSet('Online', 'Busy', 'Away', 'Offline')] + [string] + $FilterOnlineState, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/contacts"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByContactId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($Name) { + $parameters['name'] = $Name + } + if ($FilterOnlineState) { + $parameters['online_state'] = $FilterOnlineState.ToLower() + } + if ($Group) { + $groupId = $Group | Resolve-TeamViewerGroupId + $parameters['groupid'] = $groupId + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($response.contacts | ConvertTo-TeamViewerContact) +} + + + +function Get-TeamViewerCustomModuleId { + + if (Test-TeamViewerinstallation) { + $fileName = 'TeamViewer.json' + $installationDirectory = Get-TeamViewerInstallationDirectory + $filePath = Join-Path -Path $installationDirectory -ChildPath $fileName + if (Test-Path -Path $filePath) { + $jsonContent = Get-Content -Path $FilePath -Raw + $jsonObject = ConvertFrom-Json $jsonContent + if ($jsonObject.id) { + return $jsonObject.id + } + } + else { + Write-Error 'Custom module Id cannot be found. Check if customization is applied.' + } + } + else { + Write-Error 'TeamViewer is not installed' + } + +} + + + +function Get-TeamViewerDevice { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] + [Alias("DeviceId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [int] + $TeamViewerId, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateSet('Online', 'Busy', 'Away', 'Offline')] + [string] + $FilterOnlineState, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/devices"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($TeamViewerId) { + $parameters['remotecontrol_id'] = "r$TeamViewerId" + } + if ($FilterOnlineState) { + $parameters['online_state'] = $FilterOnlineState.ToLower() + } + if ($Group) { + $groupId = $Group | Resolve-TeamViewerGroupId + $parameters['groupid'] = $groupId + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($response.devices | ConvertTo-TeamViewerDevice) +} + + + +function Get-TeamViewerEventLog { + [CmdletBinding(DefaultParameterSetName = "RelativeDates")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] + [DateTime] + $StartDate, + + [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [DateTime] + $EndDate = (Get-Date), + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 12)] + [int] + $Months, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 31)] + [int] + $Days, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 24)] + [int] + $Hours, + + [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] + [ValidateRange(0, 60)] + [int] + $Minutes, + + [Parameter(Mandatory = $false)] + [int] + $Limit, + + [Parameter(Mandatory = $false)] + [ArgumentCompleter( { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + @( + 'AddRemoteWorkerDevice', + 'ChangedDisabledRemoteInput', + 'ChangedShowBlackScreen', + 'CompanyAddressBookDisabled', + 'CompanyAddressBookEnabled', + 'CompanyAddressBookMembersHid', + 'CompanyAddressBookMembersUnhid' + 'ConditionalAccessBlockMeetingStateChanged', + 'ConditionalAccessDirectoryGroupAdded', + 'ConditionalAccessDirectoryGroupDeleted', + 'ConditionalAccessDirectoryGroupMembersAdded', + 'ConditionalAccessDirectoryGroupMembersDeleted', + 'ConditionalAccessRuleAdded', + 'ConditionalAccessRuleDeleted', + 'ConditionalAccessRuleModified', + 'ConditionalAccessRuleVerificationStateChanged', + 'CreateCustomHost', + 'DeleteCustomHost', + 'EditOwnProfile', + 'EditTFAUsage', + 'EditUserPermissions', + 'EditUserProperties', + 'EmailConfirmed', + 'EndedRecording', + 'EndedSession', + 'GroupAdded', + 'GroupDeleted', + 'GroupShared', + 'GroupUpdated', + 'IncomingSession', + 'JoinCompany', + 'JoinedSession', + 'LeftSession', + 'ParticipantJoinedSession', + 'ParticipantLeftSession', + 'PausedRecording', + 'PolicyAdded', + 'PolicyDeleted', + 'PolicyUpdated', + 'ReceivedDisabledLocalInput', + 'ReceivedFile', + 'ReceivedShowBlackScreen', + 'RemoveRemoteWorkerDevice', + 'ResumedRecording', + 'ScriptTokenAdded', + 'ScriptTokenDeleted', + 'ScriptTokenUpdated', + 'SentFile', + 'StartedRecording', + 'StartedSession', + 'SwitchedSides', + 'UpdateCustomHost', + 'UserCreated', + 'UserDeleted', + 'UserGroupCreated', + 'UserGroupDeleted', + 'UserGroupMembersAdded', + 'UserGroupMembersRemoved', + 'UserGroupUpdated', + 'UserRemovedFromCompany' + ) | Where-Object { $_ -like "$wordToComplete*" } + } )] + [string[]] + $EventNames, + + [Parameter(Mandatory = $false)] + [ArgumentCompleter( { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + @( + "CompanyAddressBook", + "CompanyAdministration", + "ConditionalAccess", + "CustomModules", + "GroupManagement", + "LicenseManagement", + "Policy", + "Session", + "UserGroups", + "UserProfile" + ) | Where-Object { $_ -like "$wordToComplete*" } + })] + [string[]] + $EventTypes, + + [Parameter(Mandatory = $false)] + [ValidateScript( { $_ | Resolve-TeamViewerUserEmail } )] + [Alias("Users")] + [object[]] + $AccountEmails, + + [Parameter(Mandatory = $false)] + [string] + $AffectedItem, + + [Parameter(Mandatory = $false)] + [Alias("RemoteControlSession")] + [guid] + $RemoteControlSessionId + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/EventLogging"; + + $Limit = if ($Limit -lt 0) { $null } else { $Limit } + + if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { + $Hours = if (!$Months -And !$Days -And !$Hours -And !$Minutes) { 1 } else { $Hours } + $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) + } + + $parameters = @{ + StartDate = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + EndDate = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") + } + + if ($EventNames) { + $parameters.EventNames = $EventNames + } + if ($EventTypes) { + $parameters.EventTypes = $EventTypes + } + if ($AccountEmails) { + $parameters.AccountEmails = @($AccountEmails | Resolve-TeamViewerUserEmail) + } + if ($AffectedItem) { + $parameters.AffectedItem = $AffectedItem + } + if ($RemoteControlSessionId) { + $parameters.RCSessionGuid = $RemoteControlSessionId + } + + $remaining = $Limit + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($parameters | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $results = ($response.AuditEvents | ConvertTo-TeamViewerAuditEvent) + if ($Limit) { + Write-Output ($results | Select-Object -First $remaining) + $remaining = $remaining - @($results).Count + } + else { + Write-Output $results + } + $parameters.ContinuationToken = $response.ContinuationToken + } while ($parameters.ContinuationToken -And (!$Limit -Or $remaining -gt 0)) +} + + + +function Get-TeamViewerGroup { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByGroupId")] + [Alias("GroupId")] + [string] + $Id, + + [Parameter(ParameterSetName = "FilteredList")] + [Alias("PartialName")] + [string] + $Name, + + [Parameter(ParameterSetName = "FilteredList")] + [ValidateSet('OnlyShared', 'OnlyNotShared')] + [string] + $FilterShared + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/groups"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByGroupId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($Name) { + $parameters['name'] = $Name + } + switch ($FilterShared) { + 'OnlyShared' { $parameters['shared'] = $true } + 'OnlyNotShared' { $parameters['shared'] = $false } + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { + Write-Output ($response | ConvertTo-TeamViewerGroup) + } + else { + Write-Output ($response.groups | ConvertTo-TeamViewerGroup) + } +} + + + +function Get-TeamViewerId { + if (Test-TeamViewerInstallation) { + switch (Get-OperatingSystem) { + 'Windows' { + Write-Output (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'ClientID') + } + 'Linux' { + Write-Output (Get-TeamViewerLinuxGlobalConfig -Name 'ClientID') + } + } + } +} + + + +function Get-TeamViewerInstallationDirectory { + switch (Get-OperatingSystem) { + 'Windows' { + $regKey = Get-TeamViewerRegKeyPath + $installationDirectory = if (Test-Path $regKey) { + (Get-Item $regKey).GetValue('InstallationDirectory') + } + if ( + $installationDirectory -And ` + (Test-Path "$installationDirectory/TeamViewer.exe") + ) { + return $installationDirectory + } + } + 'Linux' { + if ( + (Test-Path '/opt/teamviewer/tv_bin/TeamViewer') + ) { + return '/opt/teamviewer/tv_bin/' + } + } + default { + Write-Error 'TeamViewer not installed' + } + } +} + + + + +function Get-TeamViewerLogFilePath { + param( + [switch] + $OpenFile + ) + + if (Test-TeamViewerInstallation) { + if (Get-OperatingSystem -eq 'Windows') { + $SearchDirectories = Get-TSCSearchDirectory + $LogFiles = New-Object System.Collections.ArrayList + foreach ($Name in $SearchDirectories.Keys) { + $SearchDirectory = $SearchDirectories[$Name] + foreach ($Folder in $SearchDirectory) { + if (Test-Path -Path $Folder) { + $files = Get-ChildItem -Path $Folder -File -Recurse + foreach ($file in $files) { + if ($file.Name.EndsWith('.log')) { + $LogFiles.add($file.FullName) | Out-Null + } + } + } + } + } + + if ($OpenFile) { + $LogFile = $host.ui.PromptForChoice('Select file', 'Choose file:', ` + @($LogFiles), 0) + Invoke-Item -Path $LogFiles[$LogFile] + } + else { + return $LogFiles + } + } + } + else { + Write-Error 'TeamViewer is not installed.' + } +} + + + +function Get-TeamViewerManagedDevice { + [CmdletBinding(DefaultParameterSetName = "List")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [Alias("Device")] + [guid] + $Id, + + [Parameter(Mandatory = $true, ParameterSetName = "ListGroup")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(ParameterSetName = "ListGroup")] + [switch] + $Pending + ) + + # default is 'List': + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices"; + $parameters = @{ } + $isListOperation = $true + + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + $resourceUri += "/$Id" + $parameters = $null + $isListOperation = $false + } + 'ListGroup' { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/$(if ($Pending) { "pending-" })devices" + } + } + + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByDeviceId') { + Write-Output ($response | ConvertTo-TeamViewerManagedDevice) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerManagedDevice) + } + } while ($isListOperation -And $parameters.paginationToken) +} + + + +function Get-TeamViewerManagedGroup { + [CmdletBinding(DefaultParameterSetName = "List")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByGroupId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } ) ] + [Alias("GroupId")] + [guid] + $Id, + + [Parameter(ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByGroupId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'ByDeviceId' { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/groups" + } + } + + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { + Write-Output ($response | ConvertTo-TeamViewerManagedGroup) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerManagedGroup) + } + } while ($PsCmdlet.ParameterSetName -In @('List', 'ByDeviceId') ` + -And $parameters.paginationToken) +} + + + +function Get-TeamViewerManagementId { + if (Test-TeamViewerInstallation) { + switch (Get-OperatingSystem) { + 'Windows' { + $regKeyPath = Join-Path (Get-TeamViewerRegKeyPath) 'DeviceManagementV2' + $regKey = if (Test-Path -LiteralPath $regKeyPath) { Get-Item -Path $regKeyPath } + if ($regKey) { + $unmanaged = [bool]($regKey.GetValue('Unmanaged')) + $managementId = $regKey.GetValue('ManagementId') + } + } + 'Linux' { + $unmanaged = [bool](Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\Unmanaged') + $managementId = Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\ManagementId' + } + } + if (!$unmanaged -And $managementId) { + Write-Output ([guid]$managementId) + } + } +} + + + +function Get-TeamViewerManager { + [CmdletBinding(DefaultParameterSetName = "ByDeviceId")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ParameterSetName = "ByDeviceId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true, ParameterSetName = "ByGroupId")] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + + $resourceUri = $null + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" + } + 'ByGroupId' { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + switch ($PsCmdlet.ParameterSetName) { + 'ByDeviceId' { + Write-Output ($response.resources | ConvertTo-TeamViewerManager -DeviceId $deviceId) + } + 'ByGroupId' { + Write-Output ($response.resources | ConvertTo-TeamViewerManager -GroupId $groupId) + } + } +} + + + +function Get-TeamViewerPolicy { + [CmdletBinding(DefaultParameterSetName = "FilteredList")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = "ByPolicyId")] + [Alias("PolicyId")] + [guid] + $Id + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies"; + $parameters = @{ } + + switch ($PsCmdlet.ParameterSetName) { + 'ByPolicyId' { + $resourceUri += "/$Id" + $parameters = $null + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output ($response.policies | ConvertTo-TeamViewerPolicy) +} + + + + +function Get-TeamViewerRoleAssignmentToAccount { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [string] + $UserRoleId + ) + + + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$UserRoleId" + $parameters = $null + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($response.ContinuationToken) { + $resourceUri += '&continuationToken=' + $response.ContinuationToken + } + Write-Output ($response.AssignedToUsers | ConvertTo-TeamViewerRoleAssignedUser ) + }while ($response.ContinuationToken) +} + + + +function Get-TeamViewerRoleAssignmentToUserGroup { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript({ $_ | Resolve-TeamviewerUserRoleId })] + [Alias('UserRole')] + [string] + $UserRoleId + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$UserRoleId" + $parameters = $null + } + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($response.ContinuationToken) { + $resourceUri += "&continuationToken=" + $response.ContinuationToken + } + Write-Output ($response.AssignedToGroups | ConvertTo-TeamViewerRoleAssignedUserGroup ) + }while ($response.ContinuationToken) + } +} + + + +function Get-TeamViewerService { + switch (Get-OperatingSystem) { + 'Windows' { + Get-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon status + } + } +} + + + +function Get-TeamViewerSsoDomain { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain"; + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response.domains | ConvertTo-TeamViewerSsoDomain) +} + + + +function Get-TeamViewerSsoExclusion { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId + ) + + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion"; + $parameters = @{ } + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + Write-Output $response.emails + $parameters.ct = $response.continuation_token + } while ($parameters.ct) +} + + + +function Get-TeamViewerUser { + [CmdletBinding(DefaultParameterSetName = 'FilteredList')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = 'ByUserId')] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias('UserId')] + [string] + $Id, + + [Parameter(ParameterSetName = 'FilteredList')] + [Alias('PartialName')] + [string] + $Name, + + [Parameter(ParameterSetName = 'FilteredList')] + [string[]] + $Email, + + [Parameter()] + [ValidateSet('All', 'Minimal')] + $PropertiesToLoad = 'All' + ) + + $parameters = @{ } + switch ($PropertiesToLoad) { + 'All' { + $parameters.full_list = $true + } + 'Minimal' { + } + } + + $resourceUri = "$(Get-TeamViewerApiUri)/users" + + switch ($PsCmdlet.ParameterSetName) { + 'ByUserId' { + $resourceUri += "/$Id" + $parameters = $null + } + 'FilteredList' { + if ($Name) { + $parameters['name'] = $Name + } + + if ($Email) { + $parameters['email'] = ($Email -join ',') + } + } + } + + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken -Uri $resourceUri -Method Get -Body $parameters -WriteErrorTo $PSCmdlet -ErrorAction Stop + + if ($PsCmdlet.ParameterSetName -Eq 'ByUserId') { + Write-Output ($response | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) + } + else { + Write-Output ($response.users | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) + } +} + + + +function Get-TeamViewerUserGroup { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" + $parameters = @{ } + $isListOperation = $true + + if ($UserGroup) { + $GroupId = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri += "/$GroupId" + $parameters = $null + $isListOperation = $false + } + } + + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + if ($UserGroup) { + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + else { + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerUserGroup) + } + } while ($isListOperation -And $parameters.paginationToken) + } +} + + + +function Get-TeamViewerUserGroupMember { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $parameters = @{ } + } + + Process { + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerUserGroupMember) + } while ($parameters.paginationToken) + } +} + + + +function Get-TeamViewerUserRole { + [CmdletBinding(DefaultParameterSetName = '')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + Begin{ + $parameters = @{ } + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + } + +Process{ + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response.Roles | ConvertTo-TeamViewerUserRole ) +} +} + + + +function Get-TeamViewerVersion { + if (Test-TeamViewerInstallation) { + switch (Get-OperatingSystem) { + 'Windows' { + return (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'Version') + } + 'Linux' { + return (Get-TeamViewerLinuxGlobalConfig -Name 'Version') + } + } + } +} + + + +function Invoke-TeamViewerPackageDownload { + Param( + [Parameter()] + [ValidateSet('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')] + [ValidateScript( { + if (($_ -ne 'Full') -And ((Get-OperatingSystem) -ne 'Windows')) { + $PSCmdlet.ThrowTerminatingError( + ("PackageType parameter is only supported on Windows platforms" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $true + })] + [string] + $PackageType, + + [Parameter()] + [ValidateScript( { + if ((Get-OperatingSystem) -ne 'Windows') { + $PSCmdlet.ThrowTerminatingError( + ("MajorVersion parameter is only supported on Windows platforms" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if($PackageType -eq 'MSI32' -or 'MSI64' ){ + $PSCmdlet.ThrowTerminatingError( + ("MajorVersion parameter is not supported for MSI packages" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($_ -lt 14) { + $PSCmdlet.ThrowTerminatingError( + ("Unsupported TeamViewer version $_" | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $true + } )] + [int] + $MajorVersion, + + [Parameter()] + [string] + $TargetDirectory = (Get-Location).Path, + + [Parameter()] + [switch] + $Force + ) + + if ((-not $PackageType) -And ((Get-OperatingSystem) -eq 'Windows')) { + $Package = $host.ui.PromptForChoice('Select Package Type', 'Choose a package type:', ` + @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit'), 0) + $PackageType = @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')[$Package] + } + + $additionalPath = '' + switch (Get-OperatingSystem) { + 'Windows' { + $filename = switch ($PackageType) { + 'Full' { 'TeamViewer_Setup.exe' } + 'MSI32' { 'TeamViewer_MSI32.zip' } + 'MSI64' { 'TeamViewer_MSI64.zip' } + 'Host' { 'TeamViewer_Host_Setup.exe' } + 'Portable' { 'TeamViewerPortable.zip' } + 'QuickJoin' { 'TeamViewerQJ.exe' } + 'QuickSupport' { 'TeamViewerQS.exe' } + 'Full64Bit' { 'TeamViewer_Setup_x64.exe' } + } + if ($MajorVersion) { + $additionalPath = "/version_$($MajorVersion)x" + } + if(($PackageType -eq 'MSI32' -or 'MSI64' )){ + $additionalPath = '/version_15x' + } + } + 'Linux' { + $releaseInfo = (Get-Content /etc/*-release) + $filename = switch -Regex ($releaseInfo) { + 'debian|ubuntu' { + $platform = if ([Environment]::Is64BitOperatingSystem) { 'amd64' } else { 'i386' } + "teamviewer_$platform.deb" + } + 'centos|rhel|fedora' { + $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } + "teamviewer.$platform.rpm" + } + 'suse|opensuse' { + $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } + "teamviewer-suse.$platform.rpm" + } + } + $filename = $filename | Select-Object -First 1 + $additionalPath = '/linux' + } + } + + $downloadUrl = "https://dl.teamviewer.com/download$additionalPath/$filename" + $targetFile = Join-Path $TargetDirectory $filename + + if ((Test-Path $targetFile) -And -Not $Force -And ` + -Not $PSCmdlet.ShouldContinue("File $targetFile already exists. Override?", "Override existing file?")) { + return + } + + Write-Verbose "Downloading $downloadUrl to $targetFile" + $client = New-Object System.Net.WebClient + $client.DownloadFile($downloadUrl, $targetFile) + Write-Output $targetFile +} + + + +function Invoke-TeamViewerPing { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/ping" + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output $result.token_valid +} + + + +function New-TeamViewerContact { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter()] + [switch] + $Invite + ) + + $body = @{ + email = $Email + groupid = $Group | Resolve-TeamViewerGroupId + } + if ($Invite) { + $body['invite'] = $true + } + + $resourceUri = "$(Get-TeamViewerApiUri)/contacts" + if ($PSCmdlet.ShouldProcess($Email, "Create contact")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response | ConvertTo-TeamViewerContact) + Write-Output $result + } +} + + + +function New-TeamViewerDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [int] + $TeamViewerId, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter()] + [Alias("Alias")] + [string] + $Name, + + [Parameter()] + [string] + $Description, + + [Parameter()] + [securestring] + $Password + ) + + $body = @{ + remotecontrol_id = "r$TeamViewerId" + groupid = $Group | Resolve-TeamViewerGroupId + } + + if ($Name) { + $body['alias'] = $Name + } + if ($Description) { + $body['description'] = $Description + } + if ($Password) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + + $resourceUri = "$(Get-TeamViewerApiUri)/devices" + if ($PSCmdlet.ShouldProcess($TeamViewerId, "Create device entry")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response | ConvertTo-TeamViewerDevice) + Write-Output $result + } +} + + + +function New-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias("PolicyId")] + [object] + $Policy + ) + + $body = @{ name = $Name } + if ($Policy) { + $body["policy_id"] = $Policy | Resolve-TeamViewerPolicyId + } + + $resourceUri = "$(Get-TeamViewerApiUri)/groups" + if ($PSCmdlet.ShouldProcess($Name, "Create group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerGroup) + } +} + + + +function New-TeamViewerManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name + ) + + $body = @{ name = $Name } + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" + if ($PSCmdlet.ShouldProcess($Name, "Create managed group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerManagedGroup) + } +} + + + +function New-TeamViewerPolicy { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name, + + [Parameter()] + [AllowEmptyCollection()] + [object[]] + $Settings, + + [Parameter()] + [switch] + $DefaultPolicy = $False + ) + + $body = @{ + name = $Name + default = [boolean]$DefaultPolicy + settings = @() + } + + if ($Settings) { + $body.settings = @($Settings) + } + + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies" + if ($PSCmdlet.ShouldProcess($Name, "Create policy")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function New-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'WithPassword')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(Mandatory = $true)] + [Alias('DisplayName')] + [string] + $Name, + + [Parameter(Mandatory = $true, ParameterSetName = 'WithPassword')] + [securestring] + $Password, + + [Parameter(ParameterSetName = 'WithoutPassword')] + [Alias('NoPassword')] + [switch] + $WithoutPassword, + + [Parameter()] + [securestring] + $SsoCustomerIdentifier, + + [Parameter()] + [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] + [cultureinfo] + $Culture + ) + + if (-Not $Culture) { + try { + $Culture = Get-Culture + } + catch { + $Culture = 'en' + } + } + + $body = @{ + email = $Email + name = $Name + language = $Culture | Resolve-TeamViewerLanguage + } + + if ($Password -And -Not $WithoutPassword) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + + if ($SsoCustomerIdentifier) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) + $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + + $resourceUri = "$(Get-TeamViewerApiUri)/users" + if ($PSCmdlet.ShouldProcess("$Name <$Email>", 'Create user')) { + $response = Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Post -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) -WriteErrorTo $PSCmdlet -ErrorAction Stop + $result = ($response | ConvertTo-TeamViewerUser) + $result.Email = $Email + + Write-Output $result + } +} + + + +function New-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [string] + $Name + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" + $body = @{ name = $Name } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, "Create user group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + } +} + + + + +function New-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true )] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('UserRoleName')] + [string] + $Name, + + [Parameter(Mandatory = $false)] + [AllowEmptyCollection()] + [object[]] + $Permissions + ) + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + $body = @{ + Name = $Name + Permissions = @() + } + + if ($Permissions) { + $body.Permissions = @($Permissions) + } + } + + Process { + if ($PSCmdlet.ShouldProcess($Name, 'Create User Role')) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = ($response.Role | ConvertTo-TeamViewerUserRole) + Write-Output $result + } + } + +} + + + +function Publish-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [object[]] + $User, + + [Parameter()] + [ValidateSet("read", "readwrite")] + $Permissions = "read" + ) + + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Permissions + + $groupId = $Group | Resolve-TeamViewerGroupId + $userIds = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/share_group" + $body = @{ + users = @($userIds | ForEach-Object { @{ + userid = $_ + permissions = $Permissions + } }) + } + + if ($PSCmdlet.ShouldProcess($userids, "Add group share")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Remove-TeamViewerAssignment { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + + if (Test-TeamViewerInstallation) { + $OS = Get-OperatingSystem + $CurrentDirectory = Get-Location + $installationDirectory = Get-TeamViewerInstallationDirectory + Set-Location $installationDirectory + if ($OS -eq 'Windows') { + $cmd = 'unassign' + $FilePath = 'TeamViewer.exe' + } + elseif ($OS -eq 'Linux') { + $cmd = 'teamviewer unassign' + $FilePath = 'sudo' + } + $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-AssignmentErrorCode + Set-Location $CurrentDirectory + } + else { + Write-Output 'TeamViewer is not installed.' + } +} + + + + + +function Remove-TeamViewerContact { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] + [Alias("ContactId")] + [Alias("Id")] + [object] + $Contact + ) + Process { + $contactId = $Contact | Resolve-TeamViewerContactId + $resourceUri = "$(Get-TeamViewerApiUri)/contacts/$contactId" + if ($PSCmdlet.ShouldProcess($contactId, "Remove contact")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerCustomization { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if (Get-OperatingSystem -eq 'Windows') { + if (Test-TeamViewerInstallation) { + $installationDirectory = Get-TeamViewerInstallationDirectory + $currentDirectory = Get-Location + Set-Location $installationDirectory + $cmd = 'customize --remove' + $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru + $process.ExitCode | Resolve-CustomizationErrorCode + Set-Location $currentDirectory + } + else { + Write-Error 'TeamViewer is not installed' + } + } + else { + Write-Error 'Customization is currently supported only on Windows.' + } +} + + + +function Remove-TeamViewerDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] + [Alias("DeviceId")] + [Alias("Id")] + [object] + $Device + ) + Process { + $deviceId = $Device | Resolve-TeamViewerDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" + if ($PSCmdlet.ShouldProcess($deviceId, "Remove device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group + ) + Process { + $groupId = $Group | Resolve-TeamViewerGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Remove group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [object] + $Group + ) + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $groupId = $Group | Resolve-TeamViewerManagedGroupId + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($deviceId, "Remove device from managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManagedDeviceManagement { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias('DeviceId')] + [object] + $Device + ) + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($deviceId, 'Remove Management from a device (clears all managers and groups)')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group + ) + Process { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Remove managed group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerManager { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "ByDeviceId")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { + if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { + $PSCmdlet.ThrowTerminatingError( + ("Invalid manager object. Manager must be a group or device manager." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $_ | Resolve-TeamViewerManagerId + })] + [Alias("ManagerId")] + [Alias("Id")] + [object] + $Manager, + + [Parameter(ParameterSetName = 'ByDeviceId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(ParameterSetName = 'ByGroupId')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] + [Alias("GroupId")] + [object] + $Group + ) + Process { + $deviceId = $null + $groupId = $null + if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { + if ($Device -Or $Group) { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($Manager.DeviceId) { + $deviceId = $Manager.DeviceId + } + elseif ($Manager.GroupId) { + $groupId = $Manager.GroupId + } + } + elseif ($Device) { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + } + elseif ($Group) { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + } + else { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $managerId = $Manager | Resolve-TeamViewerManagerId + if ($deviceId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" + $processMessage = "Remove manager from managed device" + } + elseif ($groupId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" + $processMessage = "Remove manager from managed group" + } + + if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerPolicy { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('PolicyId')] + [object] + $Policy + ) + Process { + $policyId = $Policy | Resolve-TeamViewerPolicyId + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" + + if ($PSCmdlet.ShouldProcess($policyId, "Delete policy")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamviewerPolicyFromManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(Mandatory = $true)] + [PolicyType] + $PolicyType + ) + Begin { + $body = @{ + 'policy_type' = [int]$PolicyType + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/policy/remove" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamviewerPolicyFromManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias('GroupId')] + [object] + $Group, + + [Parameter(Mandatory = $true)] + [PolicyType] + $PolicyType + ) + Begin { + $body = @{ + 'policy_type' = [int]$PolicyType + } + } + Process { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/policy/remove" + + if ($PSCmdlet.ShouldProcess($Group.ToString(), 'Change managed group entry')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerPSProxy { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + $global:TeamViewerProxyUriRemoved = $true + $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ + $global:TeamViewerProxyUriSet = $null + $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + [Environment]::SetEnvironmentVariable('TeamViewerProxyUri','', 'User') + } +} + + + +function Remove-TeamViewerRoleFromAccount { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Alias('Id', 'UserIds')] + [string[]] + $Accounts + ) + + Begin { + $id = $UserRoleId | Resolve-TeamViewerUserRoleId + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" + $AccountsToRemove = @() + $body = @{ + UserIds = @() + UserRoleId = $id + } + function Invoke-TeamViewerRestMethodInternal { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + + } + + Process { + if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from Role')) { + if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { + $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } + } + foreach ($Account in $Accounts) { + $AccountsToRemove += $Account + $body.UserIds = @($AccountsToRemove) + } + } + if ($AccountsToRemove.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $AccountsToRemove = @() + } + } + End { + if ($AccountsToRemove.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + +function Remove-TeamViewerRoleFromUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup + ) + + Begin { + $null = $ApiToken + $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/usergroup" + $body = @{ + UserGroupId = $UserGroup + } + } + + + Process { + if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign Role from User Group')) { + $result = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($result) + } + } +} + + + +function Remove-TeamViewerSsoExclusion { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [string[]] + $Email + ) + Begin { + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" + $emailsToRemove = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + + function Invoke-RequestInternal { + $body = @{ + emails = @($emailsToRemove) + } + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } + Process { + if ($PSCmdlet.ShouldProcess($Email, "Remove SSO exclusion")) { + $emailsToRemove += $Email + } + if ($emailsToRemove.Length -eq 100) { + Invoke-RequestInternal + $emailsToRemove = @() + } + } + End { + if ($emailsToRemove.Length -gt 0) { + Invoke-RequestInternal + } + } +} + + + +function Remove-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias("UserId")] + [Alias("Id")] + [object] + $User, + + [Parameter()] + [switch] + $Permanent + ) + Process { + $userId = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" + + if ($Permanent) { + $resourceUri += '?isPermanentDelete=true' + } + + if ($PSCmdlet.ShouldProcess($userId, "Remove user")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" + } + + Process { + if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Remove user group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Remove-TeamViewerUserGroupMember { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias('UserGroupId')] + [Alias('Id')] + [object] + $UserGroup, + + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] + [Alias('UserGroupMemberId')] + [Alias('MemberId')] + [Alias('UserId')] + [Alias('User')] + [object[]] + $UserGroupMember + ) + + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" + $membersToRemove = @() + $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $UserGroupMember + function Invoke-TeamViewerRestMethodInternal { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + + function Get-MemberId { + switch ($UserGroupMember) { + { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { + $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId + return $UserGroupMember + } + Default { + if ($UserGroupMember -notmatch 'u[0-9]+') { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember + } + } + else { + ForEach-Object { + $UserGroupMember = [int[]]$UserGroupMember.trim('u') + } + } + return $UserGroupMember + } + } + } + } + + Process { + # when members are provided as pipeline input, each member is provided as separate statement, + # thus the members should be combined to one array in order to send a single request + if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { + if (Get-MemberId -isnot [array]) { + $membersToRemove += @(Get-MemberId) + } + else { + $membersToRemove += Get-MemberId + } + $payload = $membersToRemove -join ', ' + $body = "[$payload]" + } + + # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` + # in order to accept more members + if ($membersToRemove.Length -eq 100) { + Invoke-TeamViewerRestMethodInternal + $membersToRemove = @() + } + } + + End { + # A request needs to be send if there were less than 100 members + if ($membersToRemove.Length -gt 0) { + Invoke-TeamViewerRestMethodInternal + } + } +} + + + +function Remove-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [Alias('Id')] + [object] + $UserRoleId + ) + + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$UserRoleId" + } + + Process { + if ($PSCmdlet.ShouldProcess($UserRoleId.ToString(), 'Remove User Role')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Delete ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Restart-TeamViewerService { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if ($PSCmdlet.ShouldProcess('TeamViewer service')) { + switch (Get-OperatingSystem) { + 'Windows' { + Restart-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon restart + } + } + } +} + + + +function Set-TeamViewerAccount { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('DisplayName')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $Password, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $OldPassword, + + [Parameter(ParameterSetName = 'ByParameters')] + [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] + [object] + $EmailLanguage, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($Name) { + $body['name'] = $Name + } + if ($Email) { + $body['email'] = $Email + } + if ($Password) { + if (-Not $OldPassword) { + $PSCmdlet.ThrowTerminatingError( + ("Old password required when attempting to change account password." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($OldPassword) + $body['oldpassword'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($EmailLanguage) { + $body['email_language'] = $EmailLanguage | Resolve-TeamViewerLanguage + } + } + 'ByProperties' { + @('name', 'email', 'password', 'oldpassword', 'email_language') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the account." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $resourceUri = "$(Get-TeamViewerApiUri)/account" + + if ($PSCmdlet.ShouldProcess("TeamViewer account")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +function Set-TeamViewerAPIUri { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [Parameter(Mandatory = $false)] + [string]$NewUri, + [Parameter(Mandatory = $false)] + [bool]$Default + ) + + $config = [TeamViewerConfiguration]::GetInstance() + $PSDefaultParameterValues = @{'CmdletName:Default' = $true } + + if ($PSCmdlet.ShouldProcess('TeamViewer account')) { + if ($NewUri) { + $config.APIUri = $NewUri + Write-Output "TeamViewer API URL set to: $($config.APIUri)" + } + elseif ($Default) { + $config.APIUri = 'https://webapi.teamviewer.com/api/v1' + Write-Output "TeamViewer API URL set to: $($config.APIUri)" + } + } + +} + + + +function Set-TeamViewerDevice { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Default")] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] + [Alias("DeviceId")] + [Alias("Id")] + [object] + $Device, + + [Parameter(ParameterSetName = "ChangeGroup")] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(ParameterSetName = "ChangePolicy")] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId -AllowInherit -AllowNone } )] + [Alias("PolicyId")] + [object] + $Policy, + + [Parameter()] + [Alias("Alias")] + [string] + $Name, + + [Parameter()] + [string] + $Description, + + [Parameter()] + [securestring] + $Password + ) + Begin { + $body = @{} + + if ($Name) { + $body['alias'] = $Name + } + if ($Description) { + $body['description'] = $Description + } + if ($Password) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($Group) { + $body['groupid'] = $Group | Resolve-TeamViewerGroupId + } + if ($Policy) { + $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId -AllowNone -AllowInherit + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the device." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change device entry")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Set-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [Alias("Id")] + [object] + $Group, + + [Parameter(ParameterSetName = 'ByParameters')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias("PolicyId")] + [object] + $Policy, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + Begin { + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + $body['name'] = $Name + if ($Policy) { + $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId + } + } + 'ByProperties' { + @('name', 'policy_id') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the group." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $groupId = $Group | Resolve-TeamViewerGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, "Update group")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Set-TeamViewerManagedDevice { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias('DeviceId')] + [object] + $Device, + + [Alias('Alias')] + [string] + $Name, + + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('PolicyId')] + [object] + $Policy, + + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] + [Alias('ManagedGroupId')] + [object] + $ManagedGroup + ) + Begin { + $body = @{} + + if ($Name) { + $body['name'] = $Name + } + if ($Policy) { + $body['teamviewerPolicyId'] = $Policy | Resolve-TeamViewerPolicyId + } + elseif ($ManagedGroup) { + $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId + } + + if ($Policy -And $ManagedGroup) { + $PSCmdlet.ThrowTerminatingError( + ('The combination of parameters -Policy and -ManagedGroup is not allowed.' | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ('The given input does not change the managed device.' | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" + + if ($PSCmdlet.ShouldProcess($Device.ToString(), 'Change managed device entry')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } +} + + + +function Set-TeamViewerManagedGroup { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] + [Alias('GroupId')] + [Alias('Id')] + [object] + $Group, + + [Parameter(ParameterSetName = 'ByParameters')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('Policy')] + [object] + $PolicyId, + + [Parameter(ParameterSetName = 'ByParameters')] + [PolicyType] + $PolicyType, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + + Begin { + # Warning suppression doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($Name) { + $body['name'] = $Name + } + + if ($PolicyId -or $PolicyType) { + if (-not ($PolicyId -and $PolicyType)) { + $PSCmdlet.ThrowTerminatingError( + ('PolicyId and PolicyType must be specified together' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $body['policy'] = @{ + 'policy_id' = $PolicyId + 'policy_type' = $PolicyType + } + } + } + 'ByProperties' { + @('name') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } + + if ($Property.ContainsKey('policy_id') -or $Property.ContainsKey('policy_type')) { + if (-not ($Property.ContainsKey('policy_id') -and $Property.ContainsKey('policy_type'))) { + $PSCmdlet.ThrowTerminatingError( + ('PolicyId and PolicyType must be specified together' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $body['policy'] = @{ + 'policy_id' = $Property['policy_id'] + 'policy_type' = [PolicyType]$Property['policy_type'] + } + } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ('The given input does not change the managed group.' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + + Process { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" + + if ($PSCmdlet.ShouldProcess($groupId, 'Update managed group')) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | Out-Null + } + } +} + + + +function Set-TeamViewerManager { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [ValidateScript( { + if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { + $PSCmdlet.ThrowTerminatingError( + ("Invalid manager object. Manager must be a group or device manager." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + $_ | Resolve-TeamViewerManagerId + })] + [Alias("ManagerId")] + [Alias("Id")] + [object] + $Manager, + + [Parameter(ParameterSetName = 'Device_ByParameters')] + [Parameter(ParameterSetName = 'Device_ByProperties')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] + [Alias("DeviceId")] + [object] + $Device, + + [Parameter(ParameterSetName = 'Group_ByParameters')] + [Parameter(ParameterSetName = 'Group_ByProperties')] + [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(ParameterSetName = 'Device_ByParameters')] + [Parameter(ParameterSetName = 'Group_ByParameters')] + [AllowEmptyCollection()] + [string[]] + $Permissions, + + [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByProperties')] + [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByProperties')] + [hashtable] + $Property + ) + Begin { + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch -Wildcard ($PSCmdlet.ParameterSetName) { + '*ByParameters' { + $body['permissions'] = @($Permissions) + } + '*ByProperties' { + @('permissions') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the manager." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + } + Process { + $deviceId = $null + $groupId = $null + if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { + if ($Device -Or $Group) { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + if ($Manager.DeviceId) { + $deviceId = $Manager.DeviceId + } + elseif ($Manager.GroupId) { + $groupId = $Manager.GroupId + } + } + elseif ($Device) { + $deviceId = $Device | Resolve-TeamViewerManagedDeviceId + } + elseif ($Group) { + $groupId = $Group | Resolve-TeamViewerManagedGroupId + } + else { + $PSCmdlet.ThrowTerminatingError( + ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $managerId = $Manager | Resolve-TeamViewerManagerId + if ($deviceId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" + $processMessage = "Update managed device manager" + } + elseif ($groupId) { + $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" + $processMessage = "Update managed group manager" + } + + if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } + } +} + + + +function Set-TeamViewerPolicy { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] + [Alias('PolicyId')] + [object] + $Policy, + + [Parameter(ParameterSetName = 'ByParameters')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [object[]] + $Settings, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + # Warning suppresion doesn't seem to work. + # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + $null = $Property + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($Name) { + $body['name'] = $Name + } + if ($Settings) { + $body['settings'] = $Settings + } + } + 'ByProperties' { + @('name', 'settings') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ("The given input does not change the policy." | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $policyId = $Policy | Resolve-TeamViewerPolicyId + $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" + + if ($PSCmdlet.ShouldProcess($policyId, "Update policy")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json -Depth 25))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + + +$global:TeamViewerProxyUriSet = $null + +function Set-TeamViewerPSProxy { + [CmdletBinding(SupportsShouldProcess =$true)] + param ( + [Parameter(Mandatory=$true)] + [Uri] + $ProxyUri + ) + + if($PSCmdlet.ShouldProcess($ProxyUri,"Sets proxy for WebAPI")){ + $global:TeamViewerProxyUriSet = $ProxyUri + $global:TeamViewerProxyUriRemoved = $false + $global:TeamViewerProxyUriRemoved | Out-Null + + [Environment]::SetEnvironmentVariable("TeamViewerProxyUri", $ProxyUri, "User") + + Write-Output "Proxy set to $TeamViewerProxyUriSet" + } +} + + + + +function Set-TeamViewerUser { + [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] + [Alias('UserId')] + [Alias('Id')] + [object] + $User, + + [Parameter(ParameterSetName = 'ByParameters')] + [boolean] + $Active, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('EmailAddress')] + [string] + $Email, + + [Parameter(ParameterSetName = 'ByParameters')] + [Alias('DisplayName')] + [string] + $Name, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $Password, + + [Parameter(ParameterSetName = 'ByParameters')] + [securestring] + $SsoCustomerIdentifier, + + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] + [hashtable] + $Property + ) + + $body = @{} + switch ($PSCmdlet.ParameterSetName) { + 'ByParameters' { + if ($PSBoundParameters.ContainsKey('Active')) { + $body['active'] = $Active + } + if ($Email) { + $body['email'] = $Email + } + if ($Name) { + $body['name'] = $Name + } + if ($Password) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) + $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + if ($SsoCustomerIdentifier) { + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) + $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null + } + } + 'ByProperties' { + @('active', 'email', 'name', 'password', 'sso_customer_id') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } + } + } + + if ($body.Count -eq 0) { + $PSCmdlet.ThrowTerminatingError( + ('The given input does not change the user.' | ` + ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) + } + + $userId = Resolve-TeamViewerUserId -User $User + $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" + + if ($PSCmdlet.ShouldProcess($userId, 'Update user profile')) { + Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Put -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) -WriteErrorTo $PSCmdlet | Out-Null + } +} + + + +function Set-TeamViewerUserGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] + [Alias("UserGroupId")] + [Alias("Id")] + [object] + $UserGroup, + + [Parameter(Mandatory = $true)] + [Alias("UserGroupName")] + [string] + $Name + ) + Begin { + $id = $UserGroup | Resolve-TeamViewerUserGroupId + $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" + $body = @{ name = $Name } + } + Process { + if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Change user group")) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + Write-Output ($response | ConvertTo-TeamViewerUserGroup) + } + } +} + + + + +function Set-TeamViewerUserRole { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true )] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [Alias('UserRoleName')] + [string] + $Name, + + [Parameter(Mandatory = $false)] + [AllowEmptyCollection()] + [object[]] + $Permissions, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] + [Alias('UserRole')] + [object] + $UserRoleId + ) + Begin { + $resourceUri = "$(Get-TeamViewerApiUri)/userroles" + $body = @{ + Name = $Name + Permissions = @() + UserRoleId = $UserRoleId + + } + if ($Permissions) { + $body.Permissions = @($Permissions) + } + } + Process { + if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Put ` + -ContentType 'application/json; charset=utf-8' ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $result = $response + Write-Output $result + } + } + +} + + + +function Start-TeamViewerService { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if ($PSCmdlet.ShouldProcess("TeamViewer service")) { + switch (Get-OperatingSystem) { + 'Windows' { + Start-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon start + } + } + } +} + + + +function Stop-TeamViewerService { + [CmdletBinding(SupportsShouldProcess = $true)] + param() + + if ($PSCmdlet.ShouldProcess("TeamViewer service")) { + switch (Get-OperatingSystem) { + 'Windows' { + Stop-Service -Name (Get-TeamViewerServiceName) + } + 'Linux' { + Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon stop + } + } + } +} + + + +function Test-TeamViewerConnectivity { + param( + [Parameter()] + [switch] + $Quiet + ) + + $endpoints = @( + @{ Hostname = 'webapi.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'login.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'meeting.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'sso.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'download.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'configdl.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'get.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'go.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'client.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'feedbackservice.teamviewer.com'; TcpPort = 443; } + @{ Hostname = 'remotescriptingstorage.blob.core.windows.net'; TcpPort = 443; } + @{ Hostname = 'chatlivestorage.blob.core.windows.net'; TcpPort = 443; } + ) + 1..16 | ForEach-Object { + $endpoints += @{ Hostname = "router$_.teamviewer.com"; TcpPort = (5938, 443, 80) } + } + + $results = $endpoints | ForEach-Object { + $endpoint = $_ + $portSucceeded = $endpoint.TcpPort | Where-Object { + Write-Verbose "Checking endpoint $($endpoint.Hostname) on port $_" + Test-TcpConnection -Hostname $endpoint.Hostname -Port $_ + } | Select-Object -First 1 + $endpoint.Succeeded = [bool]$portSucceeded + $endpoint.TcpPort = if ($endpoint.Succeeded) { $portSucceeded } else { $endpoint.TcpPort } + return $endpoint + } + + if ($Quiet) { + ![bool]($results | Where-Object { -Not $_.Succeeded }) + } + else { + $results | ` + ForEach-Object { New-Object PSObject -Property $_ } | ` + Select-Object -Property Hostname, TcpPort, Succeeded | ` + Sort-Object Hostname + } +} + + + +function Test-TeamViewerInstallation { + if (Get-TeamViewerInstallationDirectory) { + return $true + } + else { + return $false + } +} + + + +function Unpublish-TeamViewerGroup { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] + [Alias("GroupId")] + [object] + $Group, + + [Parameter(Mandatory = $true)] + [Alias("UserId")] + [object[]] + $User + ) + + $groupId = $Group | Resolve-TeamViewerGroupId + $userIds = $User | Resolve-TeamViewerUserId + $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/unshare_group" + $body = @{users = @($userIds) } + + if ($PSCmdlet.ShouldProcess($userids, "Remove group share")) { + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet | ` + Out-Null + } +} + + -@($ModuleTypes + $PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } -Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * diff --git a/Docs/Help/Remove-TeamViewerPolicyFromManagedGroup.md b/Docs/Help/Remove-TeamViewerPolicyFromManagedGroup.md new file mode 100644 index 0000000..a7ac9f1 --- /dev/null +++ b/Docs/Help/Remove-TeamViewerPolicyFromManagedGroup.md @@ -0,0 +1,160 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: [Link to Online Documentation] +schema: 2.0.0 +--- + +# Remove-TeamViewerPolicyFromManagedGroup + +## SYNOPSIS + +Remove a policy from a managed group based on type. + +Valid Types are: + +- TeamViewer +- Monitoring +- PatchManagement + +## SYNTAX + +```powershell +Remove-TeamViewerPolicyFromManagedGroup -ApiToken -Group -PolicyType [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Remove a specified policy from a managed group. + +## EXAMPLES + +### Example 1 + +Remove TeamViewer policy from group + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedGroup -Group 'd8773208-a685-4323-9de5-7f86951f8c30' -PolicyType 1 +``` + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedGroup -Group 'd8773208-a685-4323-9de5-7f86951f8c30' -PolicyType TeamViewer +``` + +### Example 2 + +Remove Monitoring policy from group + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedGroup -Group '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType 4 +``` + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedGroup -Group '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType Monitoring +``` + +### Example 3 + +Remove PatchManagement policy from group + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedGroup -Group '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType 5 +``` + +```powershell +PS /> Remove-TeamViewerPolicyFromManagedGroup -Group '730ee15a-1ea4-4d80-9cfe-5a01709d0a2f' -PolicyType PatchManagement +``` + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Group + +Object that can be used to identify the managed group. +This can either be the managed group ID (as string or GUID) or a managed group +object that has been received using other module functions. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: GroupId + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PolicyType + +The type of policy to remove from the managed group. + +```yaml +Type: PolicyType (Enum) +Parameter Sets: (All) +Aliases: +Required: True +Position: 2 +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 +``` + +### -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 +``` + +### 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.Object + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Docs/Help/Set-TeamViewerManagedGroup.md b/Docs/Help/Set-TeamViewerManagedGroup.md index 2902456..2c325c0 100644 --- a/Docs/Help/Set-TeamViewerManagedGroup.md +++ b/Docs/Help/Set-TeamViewerManagedGroup.md @@ -43,6 +43,22 @@ PS /> Set-TeamViewerManagedGroup -Group '9fd16af0-c224-4242-998e-a7138b038dbb' - Change the name of the managed group with the given ID. +### Example 2 + +```powershell +PS /> Set-TeamviewerManagedGroup -GroupId '6808db5b-f3c1-4e42-8168-3ac96f5d456e' -PolicyId '926d7a7e-b640-43a9-bc95-4f71ed7e6878' -PolicyType 4 +``` + +Change the policy of the managed group with the given ID. + +### Example 3 + +```powershell +PS /> Set-TeamViewerManagedGroup -GroupId '6808db5b-f3c1-4e42-8168-3ac96f5d456e' -Property {'policy_id' = 'e563798b-b988-4917-b1d3-a012ce6ba929' 'policy_type' = 1} +``` + +Change the policy of the managed group with the given ID using property parameters. + ## PARAMETERS ### -ApiToken @@ -111,6 +127,37 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PolicyId + +Change the policy assigned to the group and assign it the given policy. + +```yaml +Type: Object +Parameter Sets: ByParameters +Aliases: Policy + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PolicyType + +The type of policy to be set to the managed group. + +```yaml +Type: PolicyType (Enum) +Parameter Sets: (All) +Aliases: +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Property Change managed group information using a hashtable object. diff --git a/Tests/Public/Remove-TeamViewerPolicyFromManagedGroup.Tests.ps1 b/Tests/Public/Remove-TeamViewerPolicyFromManagedGroup.Tests.ps1 new file mode 100644 index 0000000..b56a10f --- /dev/null +++ b/Tests/Public/Remove-TeamViewerPolicyFromManagedGroup.Tests.ps1 @@ -0,0 +1,54 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Remove-TeamViewerPolicyFromManagedGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\TeamViewerPS.Types.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testGroupId = '9e5617cb-2b20-4da2-bca4-c1bda85b29ab' + $null = $testGroupId + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body } +} + +Describe 'Remove-TeamViewerPolicyFromManagedGroup' { + + It 'Should call the correct API endpoint to remove a policy from the managed group' { + Remove-TeamViewerPolicyFromManagedGroup -ApiToken $testApiToken -Group $testGroupId -PolicyType TeamViewer + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/managed/groups/$testGroupId/policy/remove" -And ` + $Method -eq 'Put' } + } + + It 'Should remove teamviewer policy from managed group' { + Remove-TeamViewerPolicyFromManagedGroup -Apitoken $testApiToken -Group $testGroupId -Policytype Teamviewer + $mockargs.body | Should -Not -BeNullOrEmpty + $body = [system.text.encoding]::utf8.getstring($mockargs.body) | ConvertFrom-Json + $body.policy_type | Should -Be 1 + } + + It 'Should remove monitoring policy from managed group' { + Remove-TeamViewerPolicyFromManagedGroup -Apitoken $testApiToken -Group $testGroupId -PolicyType Monitoring + $mockargs.body | Should -Not -BeNullOrEmpty + $body = [system.text.encoding]::utf8.getstring($mockargs.body) | ConvertFrom-Json + $body.policy_type | Should -Be 4 + } + + It 'Should remove patch management policy from managed group' { + Remove-TeamViewerPolicyFromManagedGroup -Apitoken $testApiToken -Group $testGroupId -PolicyType PatchManagement + $mockargs.body | Should -Not -BeNullOrEmpty + $body = [system.text.encoding]::utf8.getstring($mockargs.body) | ConvertFrom-Json + $body.policy_type | Should -Be 5 + } + + It 'Should throw an error when called with invalid policy type' { + { Remove-TeamViewerPolicyFromManagedGroup ` + -ApiToken $testApiToken ` + -Group $testGroupId -PolicyType 2 } | Should -Throw + } +} diff --git a/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 b/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 index 12eafe1..45b97df 100644 --- a/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerManagedGroup.Tests.ps1 @@ -1,5 +1,6 @@ BeforeAll { . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerManagedGroup.ps1" + . "$PSScriptRoot\..\..\Cmdlets\TeamViewerPS.Types.ps1" @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` ForEach-Object { . $_.FullName } @@ -24,18 +25,127 @@ Describe 'Set-TeamViewerManagedGroup' { $Method -eq 'Put' } } - It 'Should update the group name' { - Set-TeamViewerManagedGroup -ApiToken $testApiToken -GroupId $testGroupId -Name 'Foo Bar' + It 'Should update the TeamViewer policy ByParameters' { + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -PolicyId '9ff05c52-432c-4574-93ee-25e303fd7407' ` + -PolicyType 'TeamViewer' + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 1 + } + + It 'Should update the Monitoring policy ByParameters' { + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -PolicyId '9ff05c52-432c-4574-93ee-25e303fd7407' ` + -PolicyType 'Monitoring' + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 4 + } + + It 'Should update the Patch Management policy ByParameters' { + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -PolicyId '9ff05c52-432c-4574-93ee-25e303fd7407' ` + -PolicyType 'PatchManagement' + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 5 + } + + It 'Should update the TeamViewer policy ByProperties' { + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -Property @{ + name = 'Foo Bar' + policy_id = '9ff05c52-432c-4574-93ee-25e303fd7407' + policy_type = 'TeamViewer' + } + + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 1 + } + + It 'Should update the Monitoring policy ByProperties' { + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -Property @{ + policy_id = '9ff05c52-432c-4574-93ee-25e303fd7407' + policy_type = 'Monitoring' + } + $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json - $body.name | Should -Be 'Foo Bar' + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 4 + } + + It 'Should update the Patch Management policy ByProperties' { + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -Property @{ + policy_id = '9ff05c52-432c-4574-93ee-25e303fd7407' + policy_type = 'PatchManagement' + } + + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 5 } It 'Should accept a properties hashtable as input' { - Set-TeamViewerManagedGroup -ApiToken $testApiToken -GroupId $testGroupId -Property @{name = 'Foo Bar' } + Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -Property @{ + policy_id = '9ff05c52-432c-4574-93ee-25e303fd7407' + policy_type = 'TeamViewer' + } + $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json - $body.name | Should -Be 'Foo Bar' + $body.policy.policy_id | Should -Be '9ff05c52-432c-4574-93ee-25e303fd7407' + $body.policy.policy_type | Should -Be 1 + } + + It 'Should not be possible to set only policy_id or policy_type' { + { Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -Property @{ policy_type = 'TeamViewer' } + } | Should -Throw + + { Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -Property @{ policy_id = '9ff05c52-432c-4574-93ee-25e303fd7407' } + } | Should -Throw + + { Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -PolicyType 'PatchManagement' + } | Should -Throw + + { Set-TeamViewerManagedGroup ` + -ApiToken $testApiToken ` + -GroupId $testGroupId ` + -PolicyId '9ff05c52-432c-4574-93ee-25e303fd7407' ` + } | Should -Throw } It 'Should accept a ManagedGroup object as input' { From b8891683b2460e9cea5631f04417d78c8712b527 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV <139859343+karthickgandhiTV@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:32:34 +0100 Subject: [PATCH 099/110] Add module tests (#65) * Adds tests for manifest file * Adds basic module tests * Module Tests added * Updated New-Package build and manifest file * Rebased * Requested changes updated --------- Co-authored-by: christian.jaeckle --- Cmdlets/TeamViewerPS.psm1 | 5902 +---------------- ...le.md => Add-TeamViewerUserGroupToRole.md} | 0 ...iewerUserRole.md => Get-TeamViewerRole.md} | 0 ...iewerUserRole.md => New-TeamViewerRole.md} | 0 ...erUserRole.md => Remove-TeamViewerRole.md} | 0 Docs/Help/Set-TeamViewerAPIUri.md | 84 + ...iewerUserRole.md => Set-TeamViewerRole.md} | 0 Tests/Private/Test-ManifestFile.Tests.ps1 | 48 + .../Test-PowershellFilesValidity.Tests.ps1 | 30 + Tests/Private/Test-PrivateFunctions.Tests.ps1 | 16 + Tests/Private/Test-PublicFunctions.Tests.ps1 | 28 + ...Invoke-TeamViewerPackageDownload.Tests.ps1 | 6 + ...> Remove-TeamViewerUserFromRole.Tests.ps1} | 8 +- Tests/Public/Set-TeamViewerAPIUri.Tests.ps1 | 6 + 14 files changed, 227 insertions(+), 5901 deletions(-) rename Docs/Help/{Add-TeamViewerUserGroupToUserRole.md => Add-TeamViewerUserGroupToRole.md} (100%) rename Docs/Help/{Get-TeamViewerUserRole.md => Get-TeamViewerRole.md} (100%) rename Docs/Help/{New-TeamViewerUserRole.md => New-TeamViewerRole.md} (100%) rename Docs/Help/{Remove-TeamViewerUserRole.md => Remove-TeamViewerRole.md} (100%) create mode 100644 Docs/Help/Set-TeamViewerAPIUri.md rename Docs/Help/{Set-TeamViewerUserRole.md => Set-TeamViewerRole.md} (100%) create mode 100644 Tests/Private/Test-ManifestFile.Tests.ps1 create mode 100644 Tests/Private/Test-PowershellFilesValidity.Tests.ps1 create mode 100644 Tests/Private/Test-PrivateFunctions.Tests.ps1 create mode 100644 Tests/Private/Test-PublicFunctions.Tests.ps1 create mode 100644 Tests/Public/Invoke-TeamViewerPackageDownload.Tests.ps1 rename Tests/Public/{Remove-TeamViewerUserFromRole.ps1 => Remove-TeamViewerUserFromRole.Tests.ps1} (91%) create mode 100644 Tests/Public/Set-TeamViewerAPIUri.Tests.ps1 diff --git a/Cmdlets/TeamViewerPS.psm1 b/Cmdlets/TeamViewerPS.psm1 index a431dc0..d91058d 100644 --- a/Cmdlets/TeamViewerPS.psm1 +++ b/Cmdlets/TeamViewerPS.psm1 @@ -1,5898 +1,6 @@ -enum TeamViewerConnectionReportSessionType { - RemoteConnection = 1 - RemoteSupportActive = 2 - RemoteSupportActiveSdk = 3 -} - -enum PolicyType { - TeamViewer = 1 - Monitoring = 4 - PatchManagement = 5 -} - - - -function Add-Registry { - param ( - [Microsoft.Win32.RegistryKey]$RegKey, - [string]$Program - ) - - #CustomObject including all information for each registry and sub keys - $retRegKey = [PSCustomObject]@{ - Program = $Program - RegistryPath = $RegKey.Name - Entries = @() - } - Write-Output "Collecting registry data $($retRegKey.RegistryPath)" - foreach ($valueName in $RegKey.GetValueNames()) { - $value = $RegKey.GetValue($valueName) - $type, $value = Get-TypeAndValueOfRegistryValue -RegKey $RegKey -ValueName $valueName - $blackList = @('BuddyLoginTokenAES', 'BuddyLoginTokenSecretAES', 'Certificate', 'CertificateKey', 'CertificateKeyProtected', - 'MultiPwdMgmtPwdData', 'PermanentPassword', 'PK', 'SecurityPasswordAES', 'SK', 'SRPPasswordMachineIdentifier') - foreach ($blackListValue in $blackList) { - if ($valueName -eq $blackListValue) { - $value = '___PRIVATE___' - } - } - $entry = [PSCustomObject]@{ - Name = $valueName - Value = $value - Type = $type - } - $retRegKey.Entries += $entry - } - - foreach ($subKeyName in $RegKey.GetSubKeyNames()) { - $subKey = $RegKey.OpenSubKey($subKeyName) - Add-Registry -RegKey $subKey -Program $subKeyName - } - #Adding CustomObject to array declared in Get-RegistryPaths - $AllTVRegistryData.Add($retRegKey) | Out-Null -} - - - - - -function ConvertTo-DateTime { - param( - [Parameter(ValueFromPipeline)] - [string] - $InputString - ) - - process { - try { - Write-Output ([DateTime]::Parse($InputString)) - } - catch { - Write-Output $null - } - } -} - - -function ConvertTo-ErrorRecord { - param( - [Parameter(ValueFromPipeline)] - [object] - $InputObject, - - [Parameter()] - [System.Management.Automation.ErrorCategory] - $ErrorCategory = [System.Management.Automation.ErrorCategory]::NotSpecified - ) - Process { - $category = $ErrorCategory - $message = $InputObject.ToString() - $errorId = 'TeamViewerError' - - if ($InputObject.PSObject.TypeNames -contains 'TeamViewerPS.RestError') { - $category = switch ($InputObject.ErrorCategory) { - 'invalid_request' { [System.Management.Automation.ErrorCategory]::InvalidArgument } - 'invalid_token' { [System.Management.Automation.ErrorCategory]::AuthenticationError } - 'internal_error' { [System.Management.Automation.ErrorCategory]::NotSpecified } - 'rate_limit_reached' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } - 'token_expired' { [System.Management.Automation.ErrorCategory]::AuthenticationError } - 'wrong_credentials' { [System.Management.Automation.ErrorCategory]::AuthenticationError } - 'invalid_client' { [System.Management.Automation.ErrorCategory]::InvalidArgument } - 'not_found' { [System.Management.Automation.ErrorCategory]::ObjectNotFound } - 'too_many_retries' { [System.Management.Automation.ErrorCategory]::LimitsExceeded } - 'invalid_permission' { [System.Management.Automation.ErrorCategory]::PermissionDenied } - default { [System.Management.Automation.ErrorCategory]::NotSpecified } - } - $errorId = 'TeamViewerRestError' - } - - $exception = [System.Management.Automation.RuntimeException]($message) - $errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $category, $null - $errorRecord.ErrorDetails = $message - return $errorRecord - } -} - - - -function ConvertTo-TeamViewerAccount { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Name = $InputObject.name - Email = $InputObject.email - UserId = $InputObject.userid - CompanyName = $InputObject.company_name - IsEmailValidated = $InputObject.email_validated - EmailLanguage = $InputObject.email_language - } - if ($InputObject.email_language -And $InputObject.email_language -Ne 'auto') { - $properties["EmailLanguage"] = [System.Globalization.CultureInfo]($InputObject.email_language) - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Account') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name) <$($this.Email)>" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerAuditEvent { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Name = $InputObject.EventName - Type = $InputObject.EventType - Timestamp = $InputObject.Timestamp | ConvertTo-DateTime - Author = $InputObject.Author - AffectedItem = $InputObject.AffectedItem - EventDetails = $InputObject.EventDetails - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.AuditEvent') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "[$($this.Timestamp)] $($this.Name) ($($this.Type))" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerConnectionReport { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.id - UserId = $InputObject.userid - UserName = $InputObject.username - DeviceId = $InputObject.deviceid - DeviceName = $InputObject.devicename - GroupId = $InputObject.groupid - GroupName = $InputObject.groupname - SupportSessionType = [TeamViewerConnectionReportSessionType]$InputObject.support_session_type - StartDate = $InputObject.start_date | ConvertTo-DateTime - EndDate = $InputObject.end_date | ConvertTo-DateTime - SessionCode = $InputObject.session_code - Fee = $InputObject.fee - BillingState = $InputObject.billing_state - Currency = $InputObject.currency - Notes = $InputObject.notes - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ConnectionReport') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerContact { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.contact_id - UserId = $InputObject.user_id - GroupId = $InputObject.groupid - Name = $InputObject.name - Description = $InputObject.description - OnlineState = $InputObject.online_state - ProfilePictureUrl = $InputObject.profilepicture_url - SupportedFeatures = $InputObject.supported_features - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Contact') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerDevice { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $remoteControlId = $InputObject.remotecontrol_id | ` - Select-String -Pattern 'r(\d+)' | ` - ForEach-Object { $_.Matches.Groups[1].Value } - $properties = @{ - Id = $InputObject.device_id - TeamViewerId = $remoteControlId - GroupId = $InputObject.groupid - Name = $InputObject.alias - Description = $InputObject.description - OnlineState = $InputObject.online_state - IsAssignedToCurrentAccount = $InputObject.assigned_to - SupportedFeatures = $InputObject.supported_features - } - if ($InputObject.policy_id) { - $properties['PolicyId'] = $InputObject.policy_id - } - if ($InputObject.last_seen) { - $properties['LastSeenAt'] = [datetime]($InputObject.last_seen) - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Device') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.id - Name = $InputObject.name - Permissions = $InputObject.permissions - SharedWith = @($InputObject.shared_with | ConvertTo-TeamViewerGroupShare) - } - if ($InputObject.owner) { - $properties.Owner = [pscustomobject]@{ - UserId = $InputObject.owner.userid - Name = $InputObject.owner.name - } - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Group') - Write-Output $result - } -} - - -function ConvertTo-TeamViewerGroupShare { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - UserId = $InputObject.userid - Name = $InputObject.name - Permissions = $InputObject.permissions - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.GroupShare') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.UserId)" - } - Write-Output $result - } -} - - -function ConvertTo-TeamViewerManagedDevice { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [guid]$InputObject.id - Name = $InputObject.name - TeamViewerId = $InputObject.TeamViewerId - IsOnline = $InputObject.isOnline - } - - if ($InputObject.last_seen) { - $properties['LastSeenAt'] = Get-Date -Date $InputObject.last_seen - } - - if ($InputObject.teamviewerPolicyId) { - $properties["PolicyId"] = [guid]$InputObject.teamviewerPolicyId - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedDevice') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerManagedGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [guid]$InputObject.id - Name = $InputObject.name - } - if ($InputObject.policy_id) { - $properties["PolicyId"] = $InputObject.policy_id - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.ManagedGroup') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerManager { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject, - - [Parameter(Mandatory = $true, ParameterSetName = "GroupManager")] - [guid] - $GroupId, - - [Parameter(Mandatory = $true, ParameterSetName = "DeviceManager")] - [guid] - $DeviceId - ) - process { - $properties = @{ - Id = [guid]$InputObject.id - ManagerType = $InputObject.type - Name = $InputObject.name - Permissions = $InputObject.permissions - } - - switch ($InputObject.type) { - 'account' { - $properties.AccountId = $InputObject.accountId - } - 'company' { - $properties.CompanyId = $InputObject.companyId - } - } - - switch ($PsCmdlet.ParameterSetName) { - 'GroupManager' { - $properties.GroupId = $GroupId - } - 'DeviceManager' { - $properties.DeviceId = $DeviceId - } - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Manager') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerPolicy { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - - process { - $properties = @{ - Id = $InputObject.policy_id - Name = $InputObject.name - Settings = @( - $InputObject.settings | ForEach-Object { - @{ - Key = $_.key - Value = $_.value - Enforce = $_.enforce - } - } - ) - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.Policy') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerRestError { - param( - [parameter(ValueFromPipeline)] - $InputError - ) - Process { - try { - $errorObject = ($InputError | Out-String | ConvertFrom-Json) - $result = [PSCustomObject]@{ - Message = $errorObject.error_description - ErrorCategory = $errorObject.error - ErrorCode = $errorObject.error_code - ErrorSignature = $errorObject.error_signature - } - $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { - Write-Output "$($this.Message) ($($this.ErrorCategory))" - } - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RestError') - return $result - } - catch { - return $InputError - } - } -} - - - -function ConvertTo-TeamViewerRoleAssignedUser { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{AssignedUsers = ($InputObject.trim('u'))} - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUser') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerRoleAssignedUserGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{AssignedGroups = ($InputObject)} - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.RoleAssignedUserGroup') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerSsoDomain { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = $InputObject.DomainId - Name = $InputObject.DomainName - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.SsoDomain') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" - } - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUser { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject, - - [Parameter()] - [ValidateSet('All', 'Minimal')] - $PropertiesToLoad = 'All' - ) - - process { - $properties = @{ - Id = $InputObject.id - Name = $InputObject.name - Email = $InputObject.email - } - - if ($PropertiesToLoad -Eq 'All') { - $properties += @{ - Active = $InputObject.active - LastAccessDate = $InputObject.last_access_date | ConvertTo-DateTime - } - - if ($InputObject.activated_license_id) { - $properties += @{ - ActivatedLicenseId = [guid]$InputObject.activated_license_id - ActivatedLicenseName = $InputObject.activated_license_name - ActivatedSubLicenseName = $InputObject.activated_subLicense_name - } - } - - if ($InputObject.activated_meeting_license_key) { - $properties += @{ - ActivatedMeetingLicenseId = [guid]$InputObject.activated_meeting_license_key - } - } - } - - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.User') - $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { - Write-Output "$($this.Name) <$($this.Email)>" - } - - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUserGroup { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - Id = [UInt64]$InputObject.id - Name = $InputObject.name - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroup') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUserGroupMember { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - AccountId = [int]$InputObject.accountId - Name = $InputObject.name - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserGroupMember') - Write-Output $result - } -} - - - -function ConvertTo-TeamViewerUserRole { - param( - [Parameter(ValueFromPipeline)] - [PSObject] - $InputObject - ) - process { - $properties = @{ - RoleName = $InputObject.Name - RoleID = $InputObject.Id - } - if ($InputObject.Permissions) { - foreach ($permission in $InputObject.Permissions.PSObject.Properties) { - $properties[$permission.Name] = $permission.Value - } - } - $result = New-Object -TypeName PSObject -Property $properties - $result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.UserRole') - $result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { - Write-Output "[$($this.RoleName)] [$($this.RoleID)] $($this.Permissions))" - } - Write-Output $result - } -} - - - - -function Get-ClientId { - if (Test-Path -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer') { - $mainKey = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' - $id = [int]$mainKey.ClientID - } - elseif (Test-Path -Path 'HKLM:\Software\TeamViewer') { - $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' - $id = [int]$mainKey.ClientID - } - return $id -} - - - -function Get-HostFile { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - process { - $regPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' - $regKey = Get-ItemProperty -Path $regPath - $hostsPath = Join-Path -Path $regKey.DataBasePath -ChildPath 'hosts' - $hostsFile = Get-Content -Path $hostsPath - $hostsFile | Out-File -FilePath "$OutputPath\Data\hosts.txt" - Write-Output "hosts file collected and saved to $OutputPath\Data\hosts.txt" - } -} - - - -function Get-InstalledSoftware { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Begin { - $regUninstall = @{ - InstalledSoftware32 = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' - InstalledSoftware64 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' - } - } - Process { - foreach ($Name in $regUninstall.keys) { - $regKeys = $regUninstall[$Name] - $regKey = Get-ItemProperty -Path "$regKeys\*" - if ($null -ne $regKey) { - $subKeys = $regKey.PSChildName - if ($null -ne $subKeys) { - $installedPrograms = @() - foreach ($subKey in $subKeys) { - $tmpSubkey = Get-ItemProperty -Path "$regKeys\$subKey" - $programmName = $tmpSubkey.DisplayName - $displayVersion = $tmpSubkey.DisplayVersion - if ($null -ne $programmName) { - $tmpSoftwareData = "$programmName | $displayVersion" - $installedPrograms += $tmpSoftwareData - } - } - } - $installedPrograms | Sort-Object | Out-File -FilePath "$OutputPath\Data\$Name.txt" - Write-Output "$Name collected and saved to $OutputPath\Data\$Name.txt" - } - } - } -} - - - - - -function Get-IpConfig { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Process { - try { - ipconfig /all | Out-File -FilePath "$OutputPath\Data\ipconfig.txt" -Encoding utf8 - Write-Output "ipconfig data collected and saved to $OutputPath\Data\ipconfig.txt" - } - catch { - Write-Error "An error occurred while collecting ipconfig data: $_" - } - } -} - - - -function Get-MSInfo32 { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Process { - try { - Start-Process -FilePath msinfo32.exe -ArgumentList "/nfo $OutputPath\Data\msinfo32.nfo" -Wait - - Write-Output "msinfo data collected and saved to $OutputPath\Data\msinfo32.nfo" - } - catch { - Write-Error "An error occurred while collecting msinfo data: $_" - } - } -} - - - -function Get-NSLookUpData { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Begin { - $Ipv4DnsServer = @($null, 'tv-ns1.teamviewer.com', 'tv-ns2.teamviewer.com', 'tv-ns3.teamviewer.com', - 'tv-ns4.teamviewer.com', 'tv-ns5.teamviewer.com', '8.8.8.8', '1.1.1.1') - $Ipv4DnsName = @( 'master1.teamviewer.com', 'router1.teamviewer.com', 'google.com', - 'login.teamviewer.com', 'www.teamviewer.com') - $output = $null - } - Process { - try { - foreach ($DnsName in $Ipv4DnsName ) { - foreach ($DnsServer in $Ipv4DnsServer) { - Write-Output "Collecting nslookup.exe information from $DnsName $DnsServer. This might take a while" - $output += "nslookup information for: $DnsName $DnsServer `r`n" - $arguments = "-debug ""$DnsName""" - if ($DnsServer) { - $arguments += " ""$DnsServer""" - } - $processInfo = New-Object System.Diagnostics.ProcessStartInfo - $processInfo.FileName = 'nslookup.exe' - $processInfo.Arguments = $arguments - $processInfo.WindowStyle = 'Hidden' - $processInfo.UseShellExecute = $false - $processInfo.RedirectStandardOutput = $true - - $process = [System.Diagnostics.Process]::Start($processInfo) - $output += $process.StandardOutput.ReadToEnd() - $process.WaitForExit(60000) - if (-not $process.HasExited) { - $process.Kill() - continue - } - $output += $process.StandardOutput.ReadToEnd() - } - } - $output | Out-File "$OutputPath\Data\nslookup.txt" - } - - catch { - Write-Error "Error collecting nslookup information: $_" - } - } -} - - - - - -function Get-OperatingSystem { - if ($IsLinux) { - return 'Linux' - } - if ($IsMacOS) { - return 'MacOS' - } - if ($IsWindows -Or $env:OS -match '^Windows') { - return 'Windows' - } -} - - - -function Get-RegistryPath { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - Begin { - $SearchProgramms = @('TeamViewer', 'Blizz', 'TeamViewerMeeting') - $RegistrySearchPathsLocalMachine = @('SOFTWARE\Wow6432Node', 'SOFTWARE') - $RegistrySearchPathsCurrentUser = @('SOFTWARE') - $AllTVRegistryData = New-Object System.Collections.ArrayList - } - - Process { - foreach ($searchProgramm in $SearchProgramms) { - foreach ($registrySearchPath in $RegistrySearchPathsLocalMachine) { - $regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$registrySearchPath\$searchProgramm", $false) - if ($regKey) { - Add-Registry -RegKey $regKey -Program $searchProgramm - } - } - - foreach ($registrySearchPath in $RegistrySearchPathsCurrentUser) { - $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm", $false) - if ($searchProgramm -eq 'Blizz' -or $searchProgramm -eq 'TeamViewerMeeting') { - $regKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("$registrySearchPath\$searchProgramm\MachineFallback", $false) - } - if ($regKey) { - Add-Registry -RegKey $regKey -Program $searchProgramm - } - } - - $output = "Windows Registry Editor Version 5.00 `r`n" - foreach ($data in $AllTVRegistryData) { - $output += "[$($data.RegistryPath)]`r`n" - foreach ($entry in $data.Entries) { - if ($null -ne $entry.name) { - $output += """$($entry.Name)""" + $entry.Type + $entry.Value + "`r`n" - } - } - $output += "`r`n" - } - $output | Out-File -FilePath "$OutputPath\Data\TeamViewer_Version15\Reg_Version15.txt" - } - } - -} - - - -function Get-RouteTable { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) -Process{ - try { - $processInfo = New-Object System.Diagnostics.ProcessStartInfo - $processInfo.FileName = 'route.exe' - $processInfo.Arguments = 'print' - $processInfo.WindowStyle = 'Hidden' - $processInfo.UseShellExecute = $false - $processInfo.RedirectStandardOutput = $true - - $process = [System.Diagnostics.Process]::Start($processInfo) - $output = $process.StandardOutput.ReadToEnd() - $output | Out-File "$OutputPath\Data\RouteTable.txt" - } - catch { - Write-Error "An error occurred while collecting RouteTable data: $_" - } -} -} - - - - - -class TeamViewerConfiguration { - [string]$APIUri = 'https://webapi.teamviewer.com/api/v1' - - static [TeamViewerConfiguration] $Instance = $null - - static [TeamViewerConfiguration] GetInstance() { - if (-not [TeamViewerConfiguration]::Instance) { - [TeamViewerConfiguration]::Instance = [TeamViewerConfiguration]::new() - } - - return [TeamViewerConfiguration]::Instance - } -} - -function Get-TeamViewerAPIUri { - $config = [TeamViewerConfiguration]::GetInstance() - return $config.APIUri -} - - - - - -function Get-TeamViewerLinuxGlobalConfig { - param( - [Parameter()] - [string] - $Path = '/opt/teamviewer/config/global.conf', - - [Parameter()] - [string] - $Name - ) - $config = & sudo pwsh -command Get-Content $Path | ForEach-Object { - if ($_ -Match '\[(?\w+)\s*\]\s+(?[\w\\]+)\s+=\s*(?.*)$') { - $Matches.Remove(0) - $entry = [pscustomobject]$Matches - switch ($entry.EntryType) { - 'strng' { - $entry.EntryValue = $entry.EntryValue | ` - Select-String -Pattern '"([^\"]*)"' -AllMatches | ` - Select-Object -ExpandProperty Matches | ` - ForEach-Object { $_.Groups[1].Value } - } - 'int32' { - $entry.EntryValue = [int32]($entry.EntryValue) - } - 'int64' { - #In some cases the EntryName DeviceManagement/TransitionNonces is set to entryvalue '0 0 0 0 0' of type int64 - if ($entry.EntryValue -notmatch '0 0 0 0 0') { - $entry.EntryValue = [int64]($entry.EntryValue) - } - } - } - $entry - } - } - - if ($Name) { - ($config | Where-Object { $_.EntryName -eq $Name }).EntryValue - } - else { - $config - } -} - - - -function Get-TeamViewerRegKeyPath { - param ( - [Parameter()] - [ValidateSet('WOW6432', 'Auto')] - [string] - $Variant = 'Auto' - ) - if (($Variant -eq 'WOW6432') -Or (Test-TeamViewer32on64)) { - Write-Output 'HKLM:\SOFTWARE\Wow6432Node\TeamViewer' - } - else { - Write-Output 'HKLM:\SOFTWARE\TeamViewer' - } -} - - - -function Get-TeamViewerServiceName { - Write-Output 'TeamViewer' -} - - - -function Get-TSCDirectoryFile { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $OutputPath - ) - - Process { - $SearchDirectories = Get-TSCSearchDirectory - $TempDirectory = New-Item -Path $OutputPath -Name 'Data' -ItemType Directory -Force - $Endings = @('.log', 'tvinfo.ini', '.mdmp', 'Connections.txt', 'Connections_incoming.txt') - $TmpLogFiles = @() - foreach ($Name in $SearchDirectories.Keys) { - $SearchDirectory = $SearchDirectories[$Name] - foreach ($Folder in $SearchDirectory) { - if (Test-Path -Path $Folder) { - $TempSubdirectory = Join-Path -Path $TempDirectory -ChildPath $Name - New-Item -Path $TempSubdirectory -ItemType Directory -Force | Out-Null - $files = Get-ChildItem -Path $Folder -File -Recurse - foreach ($file in $files) { - foreach ($ending in $Endings) { - if ($file.Name.EndsWith($ending)) { - $tmpLogfilePath = Join-Path -Path $TempSubdirectory -ChildPath $file.Name - Copy-Item -Path $file.FullName -Destination $tmpLogfilePath -Force - $TmpLogFiles += $tmpLogfilePath - Write-Output "Collected log file from $($file.FullName)" - } - } - } - } - } - } - Write-Output 'Files from TeamViewer directories have been collected.' - } -} - - - -function Get-TSCSearchDirectory { - $LocalAppData = [System.Environment]::GetFolderPath('LocalApplicationData') - $RoamingAppData = [System.Environment]::GetFolderPath('ApplicationData') - $TVAppData = Join-Path -Path $LocalAppData.ToString() -ChildPath 'TeamViewer/Logs' - $TVRoamingData = Join-Path -Path $RoamingAppData.ToString() -ChildPath 'TeamViewer' - $InstallationDirectory = Get-TeamViewerInstallationDirectory - - $TSCSearchDirectory = @{ - 'TeamViewer_Version15' = $InstallationDirectory - 'AppData\TeamViewer' = @($TVAppData; $TVRoamingData) - } - - return $TSCSearchDirectory -} - - - -function Get-TypeAndValueOfRegistryValue { - param ( - [Microsoft.Win32.RegistryKey]$RegKey, - [string]$ValueName - ) - - $valueKind = $RegKey.GetValueKind($ValueName) - $type = $valueKind - - if ($valueKind -eq 'DWord') { - $type = "=dword:" - $value = [Convert]::ToInt32($RegKey.GetValue($ValueName)).ToString('x') - } - elseif ($valueKind -eq 'Binary') { - $type = "=hex:" - $value = ($RegKey.GetValue($ValueName) | ForEach-Object { $_.ToString('x2') }) -join ',' - } - elseif ($valueKind -eq 'String') { - $type = "=" - $value = $RegKey.GetValue($ValueName).ToString() - } - elseif ($valueKind -eq 'MultiString') { - $type = "=hex(7):" - $value += ($RegKey.GetValue($ValueName) | ForEach-Object { - $_.ToCharArray() | ForEach-Object { [Convert]::ToInt32($_).ToString('X') + ',00' } - }) -join ',' - $value += ',00,00,' - if ($value.Length -gt 0) { - $value += '00,00' - } - } - else { - $type = "" - $value = $RegKey.GetValue($ValueName).ToString() - } - - return $type, $value -} - - - - -function Invoke-ExternalCommand { - param( - [Parameter(Mandatory = $true, Position = 0)] - [string] - $Command, - - [Parameter(ValueFromRemainingArguments = $true)] - [object[]] - $CommandArgs - ) - & $Command @CommandArgs -} - - - -function Invoke-TeamViewerRestMethod { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [uri] - $Uri, - - [Microsoft.PowerShell.Commands.WebRequestMethod] - $Method, - - [System.Collections.IDictionary] - $Headers, - - [System.Object] - $Body, - - [string] - $ContentType, - - [System.Management.Automation.PSCmdlet] - $WriteErrorTo - - ) - - if (-Not $Headers) { - $Headers = @{ } - $PSBoundParameters.Add('Headers', $Headers) | Out-Null - } - - if ($global:TeamViewerProxyUriSet) { - $Proxy = $global:TeamViewerProxyUriSet - } - elseif ([Environment]::GetEnvironmentVariable('TeamViewerProxyUri') ) { - $Proxy = [Environment]::GetEnvironmentVariable('TeamViewerProxyUri') - if ($global:TeamViewerProxyUriRemoved) { - $Proxy = $null - } - } - If ($Proxy) { - $PSBoundParameters.Add('Proxy', $Proxy) | Out-Null - } - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ApiToken) - $Headers['Authorization'] = "Bearer $([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr))" - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - $PSBoundParameters.Remove('ApiToken') | Out-Null - $PSBoundParameters.Remove('WriteErrorTo') | Out-Null - - $currentTlsSettings = [Net.ServicePointManager]::SecurityProtocol - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - - $currentProgressPreference = $ProgressPreference - $ProgressPreference = 'SilentlyContinue' - - - # Using `Invoke-WebRequest` instead of `Invoke-RestMethod`: - # There is a known issue for PUT and DELETE operations to hang on Windows Server 2012. - try { - - return ((Invoke-WebRequest -UseBasicParsing @PSBoundParameters).Content | ConvertFrom-Json) - } - catch { - $msg = $null - if ($PSVersionTable.PSVersion.Major -ge 6) { - $msg = $_.ErrorDetails.Message - } - elseif ($_.Exception.Response) { - $stream = $_.Exception.Response.GetResponseStream() - $reader = New-Object System.IO.StreamReader($stream) - $reader.BaseStream.Position = 0 - $msg = $reader.ReadToEnd() - } - $err = ($msg | ConvertTo-TeamViewerRestError) - if ($WriteErrorTo) { - $WriteErrorTo.WriteError(($err | ConvertTo-ErrorRecord)) - } - else { - throw $err - } - } - finally { - [Net.ServicePointManager]::SecurityProtocol = $currentTlsSettings - $ProgressPreference = $currentProgressPreference - } -} - - - -function Resolve-AssignmentErrorCode { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $exitCode - ) - Begin { - $exitCodeMessages = @{ - 0 = 'Operation successful' - 1 = 'Misspelled or used a wrong command' - 2 = 'Signature verification error' - 3 = 'TeamViewer is not installed' - 4 = 'The assignment configuration could not be verified against the TeamViewer Cloud.Try again later.' - 400 = 'Invalid assignment ID' - 401 = 'TeamViewer service not running' - 402 = 'Service Incompatible Version' - 403 = 'Check your internet connection' - 404 = 'Another assignment process running' - 405 = 'Timeout' - 406 = 'Failed due to unknown reasons' - 407 = 'Access denied. Ensure local administrator rights' - 408 = 'Denied by policy' - } - } - Process { - if ($exitCode) { - if ($exitCodeMessages.ContainsKey($exitCode)) { - Write-Output $exitCodeMessages[$exitCode] - } - else { - Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" - } - } - elseif ($exitCode -eq 0) { - Write-Output $exitCodeMessages[$exitCode] - } - } -} - - - -function Resolve-CustomizationErrorCode { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $exitCode - ) - Begin { - $exitCodeMessages = @{ - 0 = 'Operation successful' - 1 = 'Invalid command line arguments' - 500 = 'An internal error occurred. See TeamViewer log files for more details!' - 501 = 'The current user was denied access' - 502 = 'The download of the custom configuration timed out' - 503 = 'Invalid Module' - 504 = 'Restart of the GUI failed' - 505 = 'Custom configuration failed. See the TeamViewer log files for more details and check if the custom configuration id is still valid.' - 506 = 'Removal of custom configuration failed. See the TeamViewer log files for more details!' - } - } - Process { - if ($exitCode) { - if ($exitCodeMessages.ContainsKey($exitCode)) { - Write-Output $exitCodeMessages[$exitCode] - } - else { - Write-Output "Unexpected error code: $exitCode. Check TeamViewer documentation!" - } - } - elseif ($exitCode -eq 0) { - Write-Output $exitCodeMessages[$exitCode] - } - } -} - - - -function Resolve-TeamViewerContactId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Contact - ) - Process { - if ($Contact.PSObject.TypeNames -contains 'TeamViewerPS.Contact') { - return $Contact.Id - } - elseif ($Contact -is [string]) { - if ($Contact -notmatch 'c[0-9]+') { - throw "Invalid contact identifier '$Contact'. String must be a contact ID in the form 'c123456789'." - } - return $Contact - } - else { - throw "Invalid contact identifier '$Contact'. Must be either a [TeamViewerPS.Contact] or [string]." - } - } -} - - - -function Resolve-TeamViewerDeviceId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Device - ) - Process { - if ($Device.PSObject.TypeNames -contains 'TeamViewerPS.Device') { - return $Device.Id - } - elseif ($Device -is [string]) { - if ($Device -notmatch 'd[0-9]+') { - throw "Invalid device identifier '$Device'. String must be a device ID in the form 'd123456789'." - } - return $Device - } - else { - throw "Invalid device identifier '$Device'. Must be either a [TeamViewerPS.Device] or [string]." - } - } -} - - - -function Resolve-TeamViewerGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Group - ) - Process { - if ($Group.PSObject.TypeNames -contains 'TeamViewerPS.Group') { - return $Group.Id - } - elseif ($Group -is [string]) { - if ($Group -notmatch 'g[0-9]+') { - throw "Invalid group identifier '$Group'. String must be a group ID in the form 'g123456789'." - } - return $Group - } - else { - throw "Invalid group identifier '$Group'. Must be either a [TeamViewerPS.Group] or [string]." - } - } -} - - - -function Resolve-TeamViewerLanguage { - param( - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [object] - $InputObject - ) - Process { - $supportedLanguages = @( - 'bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'hr', 'hu', 'id', 'it', 'ja', - 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'th', 'tr', 'uk', - 'vi', 'zh_CN', 'zh_TW', 'auto') - - $language = $InputObject - if ($InputObject -is [cultureinfo]) { - $language = switch ($InputObject.Name) { - 'zh-CN' { 'zh_CN' } - 'zh-TW' { 'zh_TW' } - default { $InputObject.TwoLetterISOLanguageName } - } - } - - if ($supportedLanguages -notcontains $language) { - throw "Invalid culture '$language'. Supported languages are: $supportedLanguages" - } - - return $language - } -} - - - -function Resolve-TeamViewerManagedDeviceId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $ManagedDevice - ) - Process { - if ($ManagedDevice.PSObject.TypeNames -contains 'TeamViewerPS.ManagedDevice') { - return [guid]$ManagedDevice.Id - } - elseif ($ManagedDevice -is [string]) { - return [guid]$ManagedDevice - } - elseif ($ManagedDevice -is [guid]) { - return $ManagedDevice - } - else { - throw "Invalid managed device identifier '$ManagedDevice'. Must be either a [TeamViewerPS.ManagedDevice], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerManagedGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $ManagedGroup - ) - Process { - if ($ManagedGroup.PSObject.TypeNames -contains 'TeamViewerPS.ManagedGroup') { - return [guid]$ManagedGroup.Id - } - elseif ($ManagedGroup -is [string]) { - return [guid]$ManagedGroup - } - elseif ($ManagedGroup -is [guid]) { - return $ManagedGroup - } - else { - throw "Invalid managed group identifier '$ManagedGroup'. Must be either a [TeamViewerPS.ManagedGroup], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerManagerId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Manager - ) - Process { - if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { - return [guid]$Manager.Id - } - elseif ($Manager -is [string]) { - return [guid]$Manager - } - elseif ($Manager -is [guid]) { - return $Manager - } - else { - throw "Invalid manager identifier '$Manager'. Must be either a [TeamViewerPS.Manager], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerPolicyId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Policy, - - [Parameter()] - [switch] - $AllowNone, - - [Parameter()] - [switch] - $AllowInherit - ) - Process { - if ($Policy.PSObject.TypeNames -contains 'TeamViewerPS.Policy') { - return [guid]$Policy.Id - } - elseif ($Policy -is [string]) { - if ($Policy -eq 'none' -And $AllowNone) { - return 'none' - } - elseif ($Policy -eq 'inherit' -And $AllowInherit) { - return 'inherit' - } - else { - return [guid]$Policy - } - } - elseif ($Policy -is [guid]) { - return $Policy - } - else { - throw "Invalid policy identifier '$Policy'. Must be either a [TeamViewerPS.Policy], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerSsoDomainId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $Domain - ) - Process { - if ($Domain.PSObject.TypeNames -contains 'TeamViewerPS.SsoDomain') { - return [guid]$Domain.Id - } - elseif ($Domain -is [string]) { - return [guid]$Domain - } - elseif ($Domain -is [guid]) { - return $Domain - } - else { - throw "Invalid SSO domain identifier '$Domain'. Must be either a [TeamViewerPS.SsoDomain], [guid] or [string]." - } - } -} - - - -function Resolve-TeamViewerUserEmail { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $false)] - [object] - $User - ) - Process { - if (!$User) { - return $null - } - elseif ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { - return $User.Email - } - elseif ($User -is [string]) { - return $User - } - else { - throw "Invalid user email '$User'. Must be either a [TeamViewerPS.User] or [string]." - } - } -} - - - -function Resolve-TeamViewerUserGroupId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserGroup - ) - Process { - if ($UserGroup.PSObject.TypeNames -contains 'TeamViewerPS.UserGroup') { - return [UInt64]$UserGroup.Id - } - elseif ($UserGroup -is [string]) { - return [UInt64]$UserGroup - } - elseif ($UserGroup -is [UInt64] -or $UserGroup -is [Int64] -or $UserGroup -is [int]) { - return [UInt64]$UserGroup - } - else { - throw "Invalid user group identifier '$UserGroup'. Must be either a [TeamViewerPS.UserGroup], [UInt64], [Int64] or [string]." - } - } -} - - - -function Resolve-TeamViewerUserGroupMemberMemberId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserGroupMember - ) - Process { - if ($UserGroupMember.PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember') { - return $UserGroupMember.AccountId - } - elseif ($UserGroupMember -match 'u[0-9]+') { - return $UserGroupMember - } - elseif ($UserGroupMember -is [string]) { - return [int]$UserGroupMember - } - elseif ($UserGroupMember -is [int]) { - return $UserGroupMember - } - else { - throw "Invalid user group identifier '$UserGroupMember'. Must be either a [TeamViewerPS.UserGroupMember],[TeamViewerPS.User] or [int] ." - } - } -} - - - -function Resolve-TeamViewerUserId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $User - ) - Process { - if ($User.PSObject.TypeNames -contains 'TeamViewerPS.User') { - return $User.Id - } - elseif ($User -is [string]) { - if ($User -notmatch 'u[0-9]+') { - throw "Invalid user identifier '$User'. String must be a user ID in the form 'u123456789'." - } - return $User - } - else { - throw "Invalid user identifier '$User'. Must be either a [TeamViewerPS.User] or [string]." - } - } -} - - - - -function Resolve-TeamViewerUserRoleId { - param( - [Parameter(ValueFromPipeline = $true, Mandatory = $true)] - [object] - $UserRole - ) - Process { - if ($UserRole.PSObject.TypeNames -contains 'TeamViewerPS.UserRole') { - return [string]$UserRole.RoleID - } - elseif ($UserRole -match '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$') { - return [string]$UserRole - } - else { - throw "Invalid role group identifier '$UserRole'. Must be either a [TeamViewerPS.UserRole] or [UUID] " - } - } -} - - - -$hasTestNetConnection = [bool](Get-Command Test-NetConnection -ErrorAction SilentlyContinue) -$hasTestConnection = [bool](Get-Command Test-Connection -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge 5.1 }) - -function Test-TcpConnection { - param( - [Parameter(Mandatory = $true)] - [string] - $Hostname, - - [Parameter(Mandatory = $true)] - [int] - $Port - ) - - if (-Not $hasTestNetConnection -And -Not $hasTestConnection) { - throw "No suitable cmdlet found for testing the TeamViewer network connectivity." - } - - $oldProgressPreference = $global:ProgressPreference - $global:ProgressPreference = 'SilentlyContinue' - - if ($hasTestNetConnection) { - Test-NetConnection -ComputerName $Hostname -Port $Port -InformationLevel Quiet -WarningAction SilentlyContinue - } - elseif ($hasTestConnection) { - Test-Connection -TargetName $Hostname -TcpPort $Port -Quiet -WarningAction SilentlyContinue - } - else { - $false - } - - $global:ProgressPreference = $oldProgressPreference -} - - - -function Test-TeamViewer32on64 { - if (![Environment]::Is64BitOperatingSystem) { - return $false - } - $registryKey = Get-TeamViewerRegKeyPath -Variant WOW6432 - if (!(Test-Path $registryKey)) { - return $false - } - try { - $installationDirectory = (Get-Item $registryKey).GetValue('InstallationDirectory') - $binaryPath = Join-Path $installationDirectory 'TeamViewer.exe' - return Test-Path $binaryPath - } - catch { - return $false - } -} - - - -function Add-TeamViewerAssignment { - param( - [Parameter(Mandatory = $true)] - [object] - $AssignmentId, - - [string] - $DeviceAlias, - - [int] - $Retries - ) - - - if (Test-TeamViewerInstallation) { - $OS = Get-OperatingSystem - $CurrentDirectory = Get-Location - $installationDirectory = Get-TeamViewerInstallationDirectory - Set-Location $installationDirectory - $CurrentVersion = Get-TeamViewerVersion - $VersionTable = $CurrentVersion.split('.') - if ($OS -eq 'Windows') { - $cmd = "assignment --id $AssignmentId" - $FilePath = 'TeamViewer.exe' - } - elseif ($OS -eq 'Linux') { - $cmd = "teamviewer assignment --id $AssignmentId" - $FilePath = 'sudo' - } - - if ($DeviceAlias) { - if (($VersionTable[0] -eq 15 -and $VersionTable[1] -ge 44) -or $VersionTable[0] -gt 15) { - $cmd += " --device-alias=$DeviceAlias" - } - else { - Write-Error "Current TeamViewer Version: $CurrentVersion does not support the usage of alias. Please update to the latest version." - Set-Location $CurrentDirectory - exit - } - } - if ($Retries) { - $cmd += " --retries=$Retries" - } - $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-AssignmentErrorCode - Set-Location $CurrentDirectory - } - else { - Write-Output 'TeamViewer is not installed.' - } -} - - - - - -Function Add-TeamViewerCustomization { - [CmdletBinding()] - param ( - [Parameter(Mandatory = $true, ParameterSetName = 'ById')] - [object] - $Id, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByPath')] - [object] - $Path, - - [switch] - $RestartGUI, - - [switch] - $RemoveExisting - ) - - if (Get-OperatingSystem -eq 'Windows') { - if (Test-TeamViewerInstallation) { - $installationDirectory = Get-TeamViewerInstallationDirectory - $currentDirectory = Get-Location - Set-Location $installationDirectory - $cmd = 'customize' - if ($Id) { - $cmd += " --id $Id" - } - elseif ($Path) { - $cmd += " --path $Path" - } - if ($RemoveExisting) { - $cmd += ' --remove' - } - if ($RestartGUI) { - $cmd += ' --restart-gui' - } - $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-CustomizationErrorCode - Set-Location $currentDirectory - } - else { - Write-Error 'TeamViewer is not installed' - } - } - else { - Write-Error 'Customization is currently supported only on Windows.' - } -} - - - -function Add-TeamViewerManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices" - - $body = @{ - id = $deviceId - } - - if ($PSCmdlet.ShouldProcess($deviceId, "Add device to managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Add-TeamViewerManager { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByAccountId')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] - [string] - $AccountId, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagerId } )] - [Alias("ManagerId")] - [object] - $Manager, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [object] - $User, - - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId })] - [Alias('UserGroupId')] - [object] - $UserGroup, - - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByAccountId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByManagerId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserObject')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByUserGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByAccountId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByManagerId')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserObject')] - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByUserGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter()] - [AllowEmptyCollection()] - [string[]] - $Permissions - ) - - $resourceUri = $null - switch -Wildcard ($PSCmdlet.ParameterSetName) { - 'Device*' { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" - $processMessage = "Add manager to managed device" - } - 'Group*' { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" - $processMessage = "Add manager to managed group" - } - } - - $body = @{} - switch -Wildcard ($PSCmdlet.ParameterSetName) { - '*ByAccountId' { - $body["accountId"] = $AccountId.TrimStart('u') - } - '*ByManagerId' { - $body["id"] = $Manager | Resolve-TeamViewerManagerId - } - '*ByUserObject' { - $body["accountId"] = ( $User | Resolve-TeamViewerUserId ).TrimStart('u') - } - '*ByUserGroupId' { - $body["usergroupId"] = $UserGroup | Resolve-TeamViewerUserGroupId - } - } - - if ($Permissions) { - $body["permissions"] = @($Permissions) - } - else { - $body["permissions"] = @() - } - - if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @($body)))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Add-TeamViewerRoleToAccount { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [object] - $UserRoleId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [Alias('Id', 'UserIds')] - [string[]] - $Accounts - ) - - Begin { - $id = $UserRoleId | Resolve-TeamViewerUserRoleId - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/account" - $AccountsToAdd = @() - $body = @{ - UserIds = @() - UserRoleId = $id - } - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - } - - - Process { - if ($PSCmdlet.ShouldProcess($Accounts, 'Assign Account to Role')) { - if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { - $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } - } - foreach ($Account in $Accounts) { - $AccountsToAdd += $Account - $body.UserIds = @($AccountsToAdd) - } - } - if ($AccountsToAdd.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $AccountsToAdd = @() - } - } - End { - if ($AccountsToAdd.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - - -function Add-TeamViewerRoleToUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRoleId')] - [object] - $UserRole, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup - ) - - Begin { - $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" - $body = @{ - UserRoleId = $RoleId - UserGroupId = $UserGroup - - } - } - - - Process { - if ($PSCmdlet.ShouldProcess($UserGroup, 'Assign Role to User Group')) { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - } -} - - - -function Add-TeamViewerSsoExclusion { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] - [Alias("Domain")] - [object] - $DomainId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [string[]] - $Email - ) - Begin { - $id = $DomainId | Resolve-TeamViewerSsoDomainId - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" - $emailsToAdd = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-RequestInternal { - $body = @{ - emails = @($emailsToAdd) - } - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } - Process { - if ($PSCmdlet.ShouldProcess($Email, "Add SSO exclusion")) { - $emailsToAdd += $Email - } - if ($emailsToAdd.Length -eq 100) { - Invoke-RequestInternal - $emailsToAdd = @() - } - } - End { - if ($emailsToAdd.Length -gt 0) { - Invoke-RequestInternal - } - } -} - - - -function Add-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [object[]] - [Alias('UserGroupMemberId')] - [Alias('UserGroupMember')] - [Alias('MemberId')] - [Alias('UserId')] - [Alias('User')] - $Member - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToAdd = @() - $body = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($result | ConvertTo-TeamViewerUserGroupMember) - } - } - - Process { - # when members are provided as pipeline input, each member is provided as a separate statement, - # thus the members should be combined into one array in order to send a single request. - if ($PSCmdlet.ShouldProcess($Member, 'Add user groups member')) { - if ($Member -notmatch 'u[0-9]+') { - ForEach-Object { - $Member = [int[]]$Member - } - } - else { - ForEach-Object { - $Member = [int[]]$Member.trim('u') - } - } - if ($Member -isnot [array]) { - $membersToAdd = @([UInt32]$Member) - } - else { - $membersToAdd += [UInt32[]]$Member - } - $payload = $membersToAdd -join ', ' - $body = "[$payload]" - } - - # WebAPI accepts a maximum of 100 accounts. Thus we send a request and reset the `membersToAdd` - # in order to accept more members - if ($membersToAdd.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $membersToAdd = @() - } - } - - End { - # A request needs to be sent if there were less than 100 members - if ($membersToAdd.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - -function Connect-TeamViewerApi { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - if (Invoke-TeamViewerPing -ApiToken $ApiToken) { - $global:PSDefaultParameterValues["*-Teamviewer*:ApiToken"] = $ApiToken - } -} - - -function Disconnect-TeamViewerApi { - $global:PSDefaultParameterValues.Remove("*-Teamviewer*:ApiToken") -} - - -function Export-TeamViewerSystemInformation { - param( - [Parameter(ValueFromPipeline = $true)] - [string] - $TargetDirectory - ) - Process { - if (Test-TeamViewerInstallation ) { - if (Get-OperatingSystem -eq 'Windows') { - $Temp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.Guid]::NewGuid().ToString()) - $CurrentDirectory = Get-Location - $Temp | Get-TSCDirectoryFile - $Temp | Get-InstalledSoftware - $Temp | Get-IpConfig - $Temp | Get-MSInfo32 - $Temp | Get-HostFile - $Temp | Get-NSLookUpData - $Temp | Get-RouteTable - $Temp | Get-RegistryPath - $ClientID = Get-ClientId - $ZipFileName = 'TV_SC_' + $ClientID + '_WINPS.zip' - $ZipPath = Join-Path -Path "$Temp\Data" -ChildPath $ZipFileName - Compress-Archive -Path $Temp\* -DestinationPath $ZipPath -Force - if ($TargetDirectory -and (Test-Path $TargetDirectory)) { - Copy-Item -Path $ZipPath -Destination $TargetDirectory -Force - } - else { - Copy-Item -Path $ZipPath -Destination $CurrentDirectory -Force - } - } - else { - Write-Error 'Currently this functionality is supported only on Windows.' - } - } - else { - Write-Error 'TeamViewer is not installed.' - } - } -} - - - -function Get-TeamViewerAccount { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/account" - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerAccount) -} - - - -function Get-TeamViewerConnectionReport { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $false)] - [string] - $UserName, - - [Parameter(Mandatory = $false)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("User")] - [object] - $UserId, - - [Parameter(Mandatory = $false)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("Group")] - [object] - $GroupId, - - [Parameter(Mandatory = $false)] - [string] - $DeviceName, - - [Parameter(Mandatory = $false)] - [int] - $DeviceId, - - [Parameter(Mandatory = $false)] - [switch] - $WithSessionCode, - - [Parameter(Mandatory = $false)] - [switch] - $WithoutSessionCode, - - [Parameter(Mandatory = $false)] - [string] - $SessionCode, - - [Parameter(Mandatory = $false)] - [TeamViewerConnectionReportSessionType] - $SupportSessionType, - - [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] - [DateTime] - $StartDate, - - [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [DateTime] - $EndDate = (Get-Date), - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 12)] - [int] - $Months, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 31)] - [int] - $Days, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 24)] - [int] - $Hours, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 60)] - [int] - $Minutes, - - [Parameter(Mandatory = $false)] - [ValidateRange(1, [int]::MaxValue)] - [int] - $Limit - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/reports/connections"; - - $parameters = @{} - - if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { - $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) - } - if ($StartDate -And $EndDate -And $StartDate -lt $EndDate) { - $parameters.from_date = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - $parameters.to_date = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - } - - if ($UserName) { - $parameters.username = $UserName - } - - if ($UserId) { - $parameters.userid = $UserId | Resolve-TeamViewerUserId - } - - if ($DeviceName) { - $parameters.devicename = $DeviceName - } - - if ($DeviceId) { - $parameters.deviceid = $DeviceId - } - - if ($GroupId) { - $parameters.groupid = $GroupId | Resolve-TeamViewerGroupId - } - - if ($WithSessionCode -And !$WithoutSessionCode) { - $parameters.has_code = $true - } - elseif ($WithoutSessionCode -And !$WithSessionCode) { - $parameters.has_code = $false - } - - if ($SessionCode) { - $parameters.session_code = $SessionCode - } - - if ($SupportSessionType) { - $parameters.support_session_type = [int]$SupportSessionType - } - - $remaining = $Limit - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $results = ($response.records | ConvertTo-TeamViewerConnectionReport) - if ($Limit) { - Write-Output ($results | Select-Object -First $remaining) - $remaining = $remaining - @($results).Count - } - else { - Write-Output $results - } - $parameters.offset_id = $response.next_offset - } while ($parameters.offset_id -And (!$Limit -Or $remaining -gt 0)) -} - - - -function Get-TeamViewerContact { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByContactId")] - [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] - [Alias("ContactId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [Alias("PartialName")] - [string] - $Name, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateSet('Online', 'Busy', 'Away', 'Offline')] - [string] - $FilterOnlineState, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/contacts"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByContactId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($Name) { - $parameters['name'] = $Name - } - if ($FilterOnlineState) { - $parameters['online_state'] = $FilterOnlineState.ToLower() - } - if ($Group) { - $groupId = $Group | Resolve-TeamViewerGroupId - $parameters['groupid'] = $groupId - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($response.contacts | ConvertTo-TeamViewerContact) -} - - - -function Get-TeamViewerCustomModuleId { - - if (Test-TeamViewerinstallation) { - $fileName = 'TeamViewer.json' - $installationDirectory = Get-TeamViewerInstallationDirectory - $filePath = Join-Path -Path $installationDirectory -ChildPath $fileName - if (Test-Path -Path $filePath) { - $jsonContent = Get-Content -Path $FilePath -Raw - $jsonObject = ConvertFrom-Json $jsonContent - if ($jsonObject.id) { - return $jsonObject.id - } - } - else { - Write-Error 'Custom module Id cannot be found. Check if customization is applied.' - } - } - else { - Write-Error 'TeamViewer is not installed' - } - -} - - - -function Get-TeamViewerDevice { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] - [Alias("DeviceId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [int] - $TeamViewerId, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateSet('Online', 'Busy', 'Away', 'Offline')] - [string] - $FilterOnlineState, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/devices"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($TeamViewerId) { - $parameters['remotecontrol_id'] = "r$TeamViewerId" - } - if ($FilterOnlineState) { - $parameters['online_state'] = $FilterOnlineState.ToLower() - } - if ($Group) { - $groupId = $Group | Resolve-TeamViewerGroupId - $parameters['groupid'] = $groupId - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($response.devices | ConvertTo-TeamViewerDevice) -} - - - -function Get-TeamViewerEventLog { - [CmdletBinding(DefaultParameterSetName = "RelativeDates")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ParameterSetName = "AbsoluteDates")] - [DateTime] - $StartDate, - - [Parameter(Mandatory = $false, ParameterSetName = "AbsoluteDates")] - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [DateTime] - $EndDate = (Get-Date), - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 12)] - [int] - $Months, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 31)] - [int] - $Days, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 24)] - [int] - $Hours, - - [Parameter(Mandatory = $false, ParameterSetName = "RelativeDates")] - [ValidateRange(0, 60)] - [int] - $Minutes, - - [Parameter(Mandatory = $false)] - [int] - $Limit, - - [Parameter(Mandatory = $false)] - [ArgumentCompleter( { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - @( - 'AddRemoteWorkerDevice', - 'ChangedDisabledRemoteInput', - 'ChangedShowBlackScreen', - 'CompanyAddressBookDisabled', - 'CompanyAddressBookEnabled', - 'CompanyAddressBookMembersHid', - 'CompanyAddressBookMembersUnhid' - 'ConditionalAccessBlockMeetingStateChanged', - 'ConditionalAccessDirectoryGroupAdded', - 'ConditionalAccessDirectoryGroupDeleted', - 'ConditionalAccessDirectoryGroupMembersAdded', - 'ConditionalAccessDirectoryGroupMembersDeleted', - 'ConditionalAccessRuleAdded', - 'ConditionalAccessRuleDeleted', - 'ConditionalAccessRuleModified', - 'ConditionalAccessRuleVerificationStateChanged', - 'CreateCustomHost', - 'DeleteCustomHost', - 'EditOwnProfile', - 'EditTFAUsage', - 'EditUserPermissions', - 'EditUserProperties', - 'EmailConfirmed', - 'EndedRecording', - 'EndedSession', - 'GroupAdded', - 'GroupDeleted', - 'GroupShared', - 'GroupUpdated', - 'IncomingSession', - 'JoinCompany', - 'JoinedSession', - 'LeftSession', - 'ParticipantJoinedSession', - 'ParticipantLeftSession', - 'PausedRecording', - 'PolicyAdded', - 'PolicyDeleted', - 'PolicyUpdated', - 'ReceivedDisabledLocalInput', - 'ReceivedFile', - 'ReceivedShowBlackScreen', - 'RemoveRemoteWorkerDevice', - 'ResumedRecording', - 'ScriptTokenAdded', - 'ScriptTokenDeleted', - 'ScriptTokenUpdated', - 'SentFile', - 'StartedRecording', - 'StartedSession', - 'SwitchedSides', - 'UpdateCustomHost', - 'UserCreated', - 'UserDeleted', - 'UserGroupCreated', - 'UserGroupDeleted', - 'UserGroupMembersAdded', - 'UserGroupMembersRemoved', - 'UserGroupUpdated', - 'UserRemovedFromCompany' - ) | Where-Object { $_ -like "$wordToComplete*" } - } )] - [string[]] - $EventNames, - - [Parameter(Mandatory = $false)] - [ArgumentCompleter( { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - $null = @($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - @( - "CompanyAddressBook", - "CompanyAdministration", - "ConditionalAccess", - "CustomModules", - "GroupManagement", - "LicenseManagement", - "Policy", - "Session", - "UserGroups", - "UserProfile" - ) | Where-Object { $_ -like "$wordToComplete*" } - })] - [string[]] - $EventTypes, - - [Parameter(Mandatory = $false)] - [ValidateScript( { $_ | Resolve-TeamViewerUserEmail } )] - [Alias("Users")] - [object[]] - $AccountEmails, - - [Parameter(Mandatory = $false)] - [string] - $AffectedItem, - - [Parameter(Mandatory = $false)] - [Alias("RemoteControlSession")] - [guid] - $RemoteControlSessionId - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/EventLogging"; - - $Limit = if ($Limit -lt 0) { $null } else { $Limit } - - if ($PSCmdlet.ParameterSetName -Eq 'RelativeDates') { - $Hours = if (!$Months -And !$Days -And !$Hours -And !$Minutes) { 1 } else { $Hours } - $StartDate = $EndDate.AddMonths(-1 * $Months).AddDays(-1 * $Days).AddHours(-1 * $Hours).AddMinutes(-1 * $Minutes) - } - - $parameters = @{ - StartDate = $StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - EndDate = $EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") - } - - if ($EventNames) { - $parameters.EventNames = $EventNames - } - if ($EventTypes) { - $parameters.EventTypes = $EventTypes - } - if ($AccountEmails) { - $parameters.AccountEmails = @($AccountEmails | Resolve-TeamViewerUserEmail) - } - if ($AffectedItem) { - $parameters.AffectedItem = $AffectedItem - } - if ($RemoteControlSessionId) { - $parameters.RCSessionGuid = $RemoteControlSessionId - } - - $remaining = $Limit - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($parameters | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $results = ($response.AuditEvents | ConvertTo-TeamViewerAuditEvent) - if ($Limit) { - Write-Output ($results | Select-Object -First $remaining) - $remaining = $remaining - @($results).Count - } - else { - Write-Output $results - } - $parameters.ContinuationToken = $response.ContinuationToken - } while ($parameters.ContinuationToken -And (!$Limit -Or $remaining -gt 0)) -} - - - -function Get-TeamViewerGroup { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByGroupId")] - [Alias("GroupId")] - [string] - $Id, - - [Parameter(ParameterSetName = "FilteredList")] - [Alias("PartialName")] - [string] - $Name, - - [Parameter(ParameterSetName = "FilteredList")] - [ValidateSet('OnlyShared', 'OnlyNotShared')] - [string] - $FilterShared - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/groups"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByGroupId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($Name) { - $parameters['name'] = $Name - } - switch ($FilterShared) { - 'OnlyShared' { $parameters['shared'] = $true } - 'OnlyNotShared' { $parameters['shared'] = $false } - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { - Write-Output ($response | ConvertTo-TeamViewerGroup) - } - else { - Write-Output ($response.groups | ConvertTo-TeamViewerGroup) - } -} - - - -function Get-TeamViewerId { - if (Test-TeamViewerInstallation) { - switch (Get-OperatingSystem) { - 'Windows' { - Write-Output (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'ClientID') - } - 'Linux' { - Write-Output (Get-TeamViewerLinuxGlobalConfig -Name 'ClientID') - } - } - } -} - - - -function Get-TeamViewerInstallationDirectory { - switch (Get-OperatingSystem) { - 'Windows' { - $regKey = Get-TeamViewerRegKeyPath - $installationDirectory = if (Test-Path $regKey) { - (Get-Item $regKey).GetValue('InstallationDirectory') - } - if ( - $installationDirectory -And ` - (Test-Path "$installationDirectory/TeamViewer.exe") - ) { - return $installationDirectory - } - } - 'Linux' { - if ( - (Test-Path '/opt/teamviewer/tv_bin/TeamViewer') - ) { - return '/opt/teamviewer/tv_bin/' - } - } - default { - Write-Error 'TeamViewer not installed' - } - } -} - - - - -function Get-TeamViewerLogFilePath { - param( - [switch] - $OpenFile - ) - - if (Test-TeamViewerInstallation) { - if (Get-OperatingSystem -eq 'Windows') { - $SearchDirectories = Get-TSCSearchDirectory - $LogFiles = New-Object System.Collections.ArrayList - foreach ($Name in $SearchDirectories.Keys) { - $SearchDirectory = $SearchDirectories[$Name] - foreach ($Folder in $SearchDirectory) { - if (Test-Path -Path $Folder) { - $files = Get-ChildItem -Path $Folder -File -Recurse - foreach ($file in $files) { - if ($file.Name.EndsWith('.log')) { - $LogFiles.add($file.FullName) | Out-Null - } - } - } - } - } - - if ($OpenFile) { - $LogFile = $host.ui.PromptForChoice('Select file', 'Choose file:', ` - @($LogFiles), 0) - Invoke-Item -Path $LogFiles[$LogFile] - } - else { - return $LogFiles - } - } - } - else { - Write-Error 'TeamViewer is not installed.' - } -} - - - -function Get-TeamViewerManagedDevice { - [CmdletBinding(DefaultParameterSetName = "List")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [Alias("Device")] - [guid] - $Id, - - [Parameter(Mandatory = $true, ParameterSetName = "ListGroup")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(ParameterSetName = "ListGroup")] - [switch] - $Pending - ) - - # default is 'List': - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices"; - $parameters = @{ } - $isListOperation = $true - - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - $resourceUri += "/$Id" - $parameters = $null - $isListOperation = $false - } - 'ListGroup' { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/$(if ($Pending) { "pending-" })devices" - } - } - - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByDeviceId') { - Write-Output ($response | ConvertTo-TeamViewerManagedDevice) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerManagedDevice) - } - } while ($isListOperation -And $parameters.paginationToken) -} - - - -function Get-TeamViewerManagedGroup { - [CmdletBinding(DefaultParameterSetName = "List")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByGroupId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } ) ] - [Alias("GroupId")] - [guid] - $Id, - - [Parameter(ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByGroupId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'ByDeviceId' { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/groups" - } - } - - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByGroupId') { - Write-Output ($response | ConvertTo-TeamViewerManagedGroup) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerManagedGroup) - } - } while ($PsCmdlet.ParameterSetName -In @('List', 'ByDeviceId') ` - -And $parameters.paginationToken) -} - - - -function Get-TeamViewerManagementId { - if (Test-TeamViewerInstallation) { - switch (Get-OperatingSystem) { - 'Windows' { - $regKeyPath = Join-Path (Get-TeamViewerRegKeyPath) 'DeviceManagementV2' - $regKey = if (Test-Path -LiteralPath $regKeyPath) { Get-Item -Path $regKeyPath } - if ($regKey) { - $unmanaged = [bool]($regKey.GetValue('Unmanaged')) - $managementId = $regKey.GetValue('ManagementId') - } - } - 'Linux' { - $unmanaged = [bool](Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\Unmanaged') - $managementId = Get-TeamViewerLinuxGlobalConfig -Name 'DeviceManagementV2\ManagementId' - } - } - if (!$unmanaged -And $managementId) { - Write-Output ([guid]$managementId) - } - } -} - - - -function Get-TeamViewerManager { - [CmdletBinding(DefaultParameterSetName = "ByDeviceId")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ParameterSetName = "ByDeviceId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true, ParameterSetName = "ByGroupId")] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - - $resourceUri = $null - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers" - } - 'ByGroupId' { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers" - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - switch ($PsCmdlet.ParameterSetName) { - 'ByDeviceId' { - Write-Output ($response.resources | ConvertTo-TeamViewerManager -DeviceId $deviceId) - } - 'ByGroupId' { - Write-Output ($response.resources | ConvertTo-TeamViewerManager -GroupId $groupId) - } - } -} - - - -function Get-TeamViewerPolicy { - [CmdletBinding(DefaultParameterSetName = "FilteredList")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = "ByPolicyId")] - [Alias("PolicyId")] - [guid] - $Id - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies"; - $parameters = @{ } - - switch ($PsCmdlet.ParameterSetName) { - 'ByPolicyId' { - $resourceUri += "/$Id" - $parameters = $null - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output ($response.policies | ConvertTo-TeamViewerPolicy) -} - - - - -function Get-TeamViewerRoleAssignmentToAccount { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [string] - $UserRoleId - ) - - - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/account?userRoleId=$UserRoleId" - $parameters = $null - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($response.ContinuationToken) { - $resourceUri += '&continuationToken=' + $response.ContinuationToken - } - Write-Output ($response.AssignedToUsers | ConvertTo-TeamViewerRoleAssignedUser ) - }while ($response.ContinuationToken) -} - - - -function Get-TeamViewerRoleAssignmentToUserGroup { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript({ $_ | Resolve-TeamviewerUserRoleId })] - [Alias('UserRole')] - [string] - $UserRoleId - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assignments/usergroups?userRoleId=$UserRoleId" - $parameters = $null - } - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($response.ContinuationToken) { - $resourceUri += "&continuationToken=" + $response.ContinuationToken - } - Write-Output ($response.AssignedToGroups | ConvertTo-TeamViewerRoleAssignedUserGroup ) - }while ($response.ContinuationToken) - } -} - - - -function Get-TeamViewerService { - switch (Get-OperatingSystem) { - 'Windows' { - Get-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon status - } - } -} - - - -function Get-TeamViewerSsoDomain { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain"; - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response.domains | ConvertTo-TeamViewerSsoDomain) -} - - - -function Get-TeamViewerSsoExclusion { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] - [Alias("Domain")] - [object] - $DomainId - ) - - $id = $DomainId | Resolve-TeamViewerSsoDomainId - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion"; - $parameters = @{ } - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - Write-Output $response.emails - $parameters.ct = $response.continuation_token - } while ($parameters.ct) -} - - - -function Get-TeamViewerUser { - [CmdletBinding(DefaultParameterSetName = 'FilteredList')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = 'ByUserId')] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias('UserId')] - [string] - $Id, - - [Parameter(ParameterSetName = 'FilteredList')] - [Alias('PartialName')] - [string] - $Name, - - [Parameter(ParameterSetName = 'FilteredList')] - [string[]] - $Email, - - [Parameter()] - [ValidateSet('All', 'Minimal')] - $PropertiesToLoad = 'All' - ) - - $parameters = @{ } - switch ($PropertiesToLoad) { - 'All' { - $parameters.full_list = $true - } - 'Minimal' { - } - } - - $resourceUri = "$(Get-TeamViewerApiUri)/users" - - switch ($PsCmdlet.ParameterSetName) { - 'ByUserId' { - $resourceUri += "/$Id" - $parameters = $null - } - 'FilteredList' { - if ($Name) { - $parameters['name'] = $Name - } - - if ($Email) { - $parameters['email'] = ($Email -join ',') - } - } - } - - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken -Uri $resourceUri -Method Get -Body $parameters -WriteErrorTo $PSCmdlet -ErrorAction Stop - - if ($PsCmdlet.ParameterSetName -Eq 'ByUserId') { - Write-Output ($response | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) - } - else { - Write-Output ($response.users | ConvertTo-TeamViewerUser -PropertiesToLoad $PropertiesToLoad) - } -} - - - -function Get-TeamViewerUserGroup { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" - $parameters = @{ } - $isListOperation = $true - - if ($UserGroup) { - $GroupId = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri += "/$GroupId" - $parameters = $null - $isListOperation = $false - } - } - - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - if ($UserGroup) { - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - else { - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerUserGroup) - } - } while ($isListOperation -And $parameters.paginationToken) - } -} - - - -function Get-TeamViewerUserGroupMember { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $parameters = @{ } - } - - Process { - do { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - $parameters.paginationToken = $response.nextPaginationToken - Write-Output ($response.resources | ConvertTo-TeamViewerUserGroupMember) - } while ($parameters.paginationToken) - } -} - - - -function Get-TeamViewerUserRole { - [CmdletBinding(DefaultParameterSetName = '')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - Begin{ - $parameters = @{ } - $resourceUri = "$(Get-TeamViewerApiUri)/userroles" - } - -Process{ - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -Body $parameters ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response.Roles | ConvertTo-TeamViewerUserRole ) -} -} - - - -function Get-TeamViewerVersion { - if (Test-TeamViewerInstallation) { - switch (Get-OperatingSystem) { - 'Windows' { - return (Get-ItemPropertyValue -Path (Get-TeamViewerRegKeyPath) -Name 'Version') - } - 'Linux' { - return (Get-TeamViewerLinuxGlobalConfig -Name 'Version') - } - } - } -} - - - -function Invoke-TeamViewerPackageDownload { - Param( - [Parameter()] - [ValidateSet('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')] - [ValidateScript( { - if (($_ -ne 'Full') -And ((Get-OperatingSystem) -ne 'Windows')) { - $PSCmdlet.ThrowTerminatingError( - ("PackageType parameter is only supported on Windows platforms" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $true - })] - [string] - $PackageType, - - [Parameter()] - [ValidateScript( { - if ((Get-OperatingSystem) -ne 'Windows') { - $PSCmdlet.ThrowTerminatingError( - ("MajorVersion parameter is only supported on Windows platforms" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if($PackageType -eq 'MSI32' -or 'MSI64' ){ - $PSCmdlet.ThrowTerminatingError( - ("MajorVersion parameter is not supported for MSI packages" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if ($_ -lt 14) { - $PSCmdlet.ThrowTerminatingError( - ("Unsupported TeamViewer version $_" | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $true - } )] - [int] - $MajorVersion, - - [Parameter()] - [string] - $TargetDirectory = (Get-Location).Path, - - [Parameter()] - [switch] - $Force - ) - - if ((-not $PackageType) -And ((Get-OperatingSystem) -eq 'Windows')) { - $Package = $host.ui.PromptForChoice('Select Package Type', 'Choose a package type:', ` - @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit'), 0) - $PackageType = @('Full', 'Host', 'MSI32', 'MSI64', 'Portable', 'QuickJoin', 'QuickSupport', 'Full64Bit')[$Package] - } - - $additionalPath = '' - switch (Get-OperatingSystem) { - 'Windows' { - $filename = switch ($PackageType) { - 'Full' { 'TeamViewer_Setup.exe' } - 'MSI32' { 'TeamViewer_MSI32.zip' } - 'MSI64' { 'TeamViewer_MSI64.zip' } - 'Host' { 'TeamViewer_Host_Setup.exe' } - 'Portable' { 'TeamViewerPortable.zip' } - 'QuickJoin' { 'TeamViewerQJ.exe' } - 'QuickSupport' { 'TeamViewerQS.exe' } - 'Full64Bit' { 'TeamViewer_Setup_x64.exe' } - } - if ($MajorVersion) { - $additionalPath = "/version_$($MajorVersion)x" - } - if(($PackageType -eq 'MSI32' -or 'MSI64' )){ - $additionalPath = '/version_15x' - } - } - 'Linux' { - $releaseInfo = (Get-Content /etc/*-release) - $filename = switch -Regex ($releaseInfo) { - 'debian|ubuntu' { - $platform = if ([Environment]::Is64BitOperatingSystem) { 'amd64' } else { 'i386' } - "teamviewer_$platform.deb" - } - 'centos|rhel|fedora' { - $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } - "teamviewer.$platform.rpm" - } - 'suse|opensuse' { - $platform = if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } - "teamviewer-suse.$platform.rpm" - } - } - $filename = $filename | Select-Object -First 1 - $additionalPath = '/linux' - } - } - - $downloadUrl = "https://dl.teamviewer.com/download$additionalPath/$filename" - $targetFile = Join-Path $TargetDirectory $filename - - if ((Test-Path $targetFile) -And -Not $Force -And ` - -Not $PSCmdlet.ShouldContinue("File $targetFile already exists. Override?", "Override existing file?")) { - return - } - - Write-Verbose "Downloading $downloadUrl to $targetFile" - $client = New-Object System.Net.WebClient - $client.DownloadFile($downloadUrl, $targetFile) - Write-Output $targetFile -} - - - -function Invoke-TeamViewerPing { - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken - ) - - $resourceUri = "$(Get-TeamViewerApiUri)/ping" - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Get ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output $result.token_valid -} - - - -function New-TeamViewerContact { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter()] - [switch] - $Invite - ) - - $body = @{ - email = $Email - groupid = $Group | Resolve-TeamViewerGroupId - } - if ($Invite) { - $body['invite'] = $true - } - - $resourceUri = "$(Get-TeamViewerApiUri)/contacts" - if ($PSCmdlet.ShouldProcess($Email, "Create contact")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response | ConvertTo-TeamViewerContact) - Write-Output $result - } -} - - - -function New-TeamViewerDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [int] - $TeamViewerId, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter()] - [Alias("Alias")] - [string] - $Name, - - [Parameter()] - [string] - $Description, - - [Parameter()] - [securestring] - $Password - ) - - $body = @{ - remotecontrol_id = "r$TeamViewerId" - groupid = $Group | Resolve-TeamViewerGroupId - } - - if ($Name) { - $body['alias'] = $Name - } - if ($Description) { - $body['description'] = $Description - } - if ($Password) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - - $resourceUri = "$(Get-TeamViewerApiUri)/devices" - if ($PSCmdlet.ShouldProcess($TeamViewerId, "Create device entry")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response | ConvertTo-TeamViewerDevice) - Write-Output $result - } -} - - - -function New-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias("PolicyId")] - [object] - $Policy - ) - - $body = @{ name = $Name } - if ($Policy) { - $body["policy_id"] = $Policy | Resolve-TeamViewerPolicyId - } - - $resourceUri = "$(Get-TeamViewerApiUri)/groups" - if ($PSCmdlet.ShouldProcess($Name, "Create group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerGroup) - } -} - - - -function New-TeamViewerManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name - ) - - $body = @{ name = $Name } - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups" - if ($PSCmdlet.ShouldProcess($Name, "Create managed group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerManagedGroup) - } -} - - - -function New-TeamViewerPolicy { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name, - - [Parameter()] - [AllowEmptyCollection()] - [object[]] - $Settings, - - [Parameter()] - [switch] - $DefaultPolicy = $False - ) - - $body = @{ - name = $Name - default = [boolean]$DefaultPolicy - settings = @() - } - - if ($Settings) { - $body.settings = @($Settings) - } - - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies" - if ($PSCmdlet.ShouldProcess($Name, "Create policy")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function New-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'WithPassword')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(Mandatory = $true)] - [Alias('DisplayName')] - [string] - $Name, - - [Parameter(Mandatory = $true, ParameterSetName = 'WithPassword')] - [securestring] - $Password, - - [Parameter(ParameterSetName = 'WithoutPassword')] - [Alias('NoPassword')] - [switch] - $WithoutPassword, - - [Parameter()] - [securestring] - $SsoCustomerIdentifier, - - [Parameter()] - [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] - [cultureinfo] - $Culture - ) - - if (-Not $Culture) { - try { - $Culture = Get-Culture - } - catch { - $Culture = 'en' - } - } - - $body = @{ - email = $Email - name = $Name - language = $Culture | Resolve-TeamViewerLanguage - } - - if ($Password -And -Not $WithoutPassword) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - - if ($SsoCustomerIdentifier) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) - $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - - $resourceUri = "$(Get-TeamViewerApiUri)/users" - if ($PSCmdlet.ShouldProcess("$Name <$Email>", 'Create user')) { - $response = Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Post -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) -WriteErrorTo $PSCmdlet -ErrorAction Stop - $result = ($response | ConvertTo-TeamViewerUser) - $result.Email = $Email - - Write-Output $result - } -} - - - -function New-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [string] - $Name - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups" - $body = @{ name = $Name } - } - - Process { - if ($PSCmdlet.ShouldProcess($Name, "Create user group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - } -} - - - - -function New-TeamViewerUserRole { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true )] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('UserRoleName')] - [string] - $Name, - - [Parameter(Mandatory = $false)] - [AllowEmptyCollection()] - [object[]] - $Permissions - ) - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles" - $body = @{ - Name = $Name - Permissions = @() - } - - if ($Permissions) { - $body.Permissions = @($Permissions) - } - } - - Process { - if ($PSCmdlet.ShouldProcess($Name, 'Create User Role')) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = ($response.Role | ConvertTo-TeamViewerUserRole) - Write-Output $result - } - } - -} - - - -function Publish-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [object[]] - $User, - - [Parameter()] - [ValidateSet("read", "readwrite")] - $Permissions = "read" - ) - - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Permissions - - $groupId = $Group | Resolve-TeamViewerGroupId - $userIds = $User | Resolve-TeamViewerUserId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/share_group" - $body = @{ - users = @($userIds | ForEach-Object { @{ - userid = $_ - permissions = $Permissions - } }) - } - - if ($PSCmdlet.ShouldProcess($userids, "Add group share")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Remove-TeamViewerAssignment { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - - if (Test-TeamViewerInstallation) { - $OS = Get-OperatingSystem - $CurrentDirectory = Get-Location - $installationDirectory = Get-TeamViewerInstallationDirectory - Set-Location $installationDirectory - if ($OS -eq 'Windows') { - $cmd = 'unassign' - $FilePath = 'TeamViewer.exe' - } - elseif ($OS -eq 'Linux') { - $cmd = 'teamviewer unassign' - $FilePath = 'sudo' - } - $process = Start-Process -FilePath $FilePath -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-AssignmentErrorCode - Set-Location $CurrentDirectory - } - else { - Write-Output 'TeamViewer is not installed.' - } -} - - - - - -function Remove-TeamViewerContact { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerContactId } )] - [Alias("ContactId")] - [Alias("Id")] - [object] - $Contact - ) - Process { - $contactId = $Contact | Resolve-TeamViewerContactId - $resourceUri = "$(Get-TeamViewerApiUri)/contacts/$contactId" - if ($PSCmdlet.ShouldProcess($contactId, "Remove contact")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerCustomization { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if (Get-OperatingSystem -eq 'Windows') { - if (Test-TeamViewerInstallation) { - $installationDirectory = Get-TeamViewerInstallationDirectory - $currentDirectory = Get-Location - Set-Location $installationDirectory - $cmd = 'customize --remove' - $process = Start-Process -FilePath TeamViewer.exe -ArgumentList $cmd -Wait -PassThru - $process.ExitCode | Resolve-CustomizationErrorCode - Set-Location $currentDirectory - } - else { - Write-Error 'TeamViewer is not installed' - } - } - else { - Write-Error 'Customization is currently supported only on Windows.' - } -} - - - -function Remove-TeamViewerDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] - [Alias("DeviceId")] - [Alias("Id")] - [object] - $Device - ) - Process { - $deviceId = $Device | Resolve-TeamViewerDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" - if ($PSCmdlet.ShouldProcess($deviceId, "Remove device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group - ) - Process { - $groupId = $Group | Resolve-TeamViewerGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Remove group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [object] - $Group - ) - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $groupId = $Group | Resolve-TeamViewerManagedGroupId - - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($deviceId, "Remove device from managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManagedDeviceManagement { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias('DeviceId')] - [object] - $Device - ) - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($deviceId, 'Remove Management from a device (clears all managers and groups)')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group - ) - Process { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Remove managed group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerManager { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "ByDeviceId")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { - if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { - $PSCmdlet.ThrowTerminatingError( - ("Invalid manager object. Manager must be a group or device manager." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $_ | Resolve-TeamViewerManagerId - })] - [Alias("ManagerId")] - [Alias("Id")] - [object] - $Manager, - - [Parameter(ParameterSetName = 'ByDeviceId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(ParameterSetName = 'ByGroupId')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias("GroupId")] - [object] - $Group - ) - Process { - $deviceId = $null - $groupId = $null - if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { - if ($Device -Or $Group) { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if ($Manager.DeviceId) { - $deviceId = $Manager.DeviceId - } - elseif ($Manager.GroupId) { - $groupId = $Manager.GroupId - } - } - elseif ($Device) { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - } - elseif ($Group) { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - } - else { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $managerId = $Manager | Resolve-TeamViewerManagerId - if ($deviceId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" - $processMessage = "Remove manager from managed device" - } - elseif ($groupId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" - $processMessage = "Remove manager from managed group" - } - - if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerPolicy { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias('PolicyId')] - [object] - $Policy - ) - Process { - $policyId = $Policy | Resolve-TeamViewerPolicyId - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" - - if ($PSCmdlet.ShouldProcess($policyId, "Delete policy")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamviewerPolicyFromManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(Mandatory = $true)] - [PolicyType] - $PolicyType - ) - Begin { - $body = @{ - 'policy_type' = [int]$PolicyType - } - } - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/policy/remove" - - if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change managed device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamviewerPolicyFromManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias('GroupId')] - [object] - $Group, - - [Parameter(Mandatory = $true)] - [PolicyType] - $PolicyType - ) - Begin { - $body = @{ - 'policy_type' = [int]$PolicyType - } - } - Process { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/policy/remove" - - if ($PSCmdlet.ShouldProcess($Group.ToString(), 'Change managed group entry')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerPSProxy { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - $global:TeamViewerProxyUriRemoved = $true - $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ - $global:TeamViewerProxyUriSet = $null - $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - [Environment]::SetEnvironmentVariable('TeamViewerProxyUri','', 'User') - } -} - - - -function Remove-TeamViewerRoleFromAccount { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [object] - $UserRoleId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] - [Alias('Id', 'UserIds')] - [string[]] - $Accounts - ) - - Begin { - $id = $UserRoleId | Resolve-TeamViewerUserRoleId - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/account" - $AccountsToRemove = @() - $body = @{ - UserIds = @() - UserRoleId = $id - } - function Invoke-TeamViewerRestMethodInternal { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - - } - - Process { - if ($PSCmdlet.ShouldProcess($Accounts, 'Unassign Account from Role')) { - if (($Accounts -notmatch 'u[0-9]+') -and ($Accounts -match '[0-9]+')) { - $Accounts = $Accounts | ForEach-Object { $_.Insert(0, 'u') } - } - foreach ($Account in $Accounts) { - $AccountsToRemove += $Account - $body.UserIds = @($AccountsToRemove) - } - } - if ($AccountsToRemove.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $AccountsToRemove = @() - } - } - End { - if ($AccountsToRemove.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - -function Remove-TeamViewerRoleFromUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup - ) - - Begin { - $null = $ApiToken - $resourceUri = "$(Get-TeamViewerApiUri)/userroles/unassign/usergroup" - $body = @{ - UserGroupId = $UserGroup - } - } - - - Process { - if ($PSCmdlet.ShouldProcess($UserGroupId, 'Unassign Role from User Group')) { - $result = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($result) - } - } -} - - - -function Remove-TeamViewerSsoExclusion { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] - [Alias("Domain")] - [object] - $DomainId, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [string[]] - $Email - ) - Begin { - $id = $DomainId | Resolve-TeamViewerSsoDomainId - $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/exclusion" - $emailsToRemove = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - - function Invoke-RequestInternal { - $body = @{ - emails = @($emailsToRemove) - } - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } - Process { - if ($PSCmdlet.ShouldProcess($Email, "Remove SSO exclusion")) { - $emailsToRemove += $Email - } - if ($emailsToRemove.Length -eq 100) { - Invoke-RequestInternal - $emailsToRemove = @() - } - } - End { - if ($emailsToRemove.Length -gt 0) { - Invoke-RequestInternal - } - } -} - - - -function Remove-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias("UserId")] - [Alias("Id")] - [object] - $User, - - [Parameter()] - [switch] - $Permanent - ) - Process { - $userId = $User | Resolve-TeamViewerUserId - $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" - - if ($Permanent) { - $resourceUri += '?isPermanentDelete=true' - } - - if ($PSCmdlet.ShouldProcess($userId, "Remove user")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" - } - - Process { - if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Remove user group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Remove-TeamViewerUserGroupMember { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByUserGroupMemberId')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias('UserGroupId')] - [Alias('Id')] - [object] - $UserGroup, - - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupMemberMemberId } )] - [Alias('UserGroupMemberId')] - [Alias('MemberId')] - [Alias('UserId')] - [Alias('User')] - [object[]] - $UserGroupMember - ) - - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id/members" - $membersToRemove = @() - $null = $ApiToken # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $UserGroupMember - function Invoke-TeamViewerRestMethodInternal { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - - function Get-MemberId { - switch ($UserGroupMember) { - { $UserGroupMember[0].PSObject.TypeNames -contains 'TeamViewerPS.UserGroupMember' } { - $UserGroupMember = $UserGroupMember | Resolve-TeamViewerUserGroupMemberMemberId - return $UserGroupMember - } - Default { - if ($UserGroupMember -notmatch 'u[0-9]+') { - ForEach-Object { - $UserGroupMember = [int[]]$UserGroupMember - } - } - else { - ForEach-Object { - $UserGroupMember = [int[]]$UserGroupMember.trim('u') - } - } - return $UserGroupMember - } - } - } - } - - Process { - # when members are provided as pipeline input, each member is provided as separate statement, - # thus the members should be combined to one array in order to send a single request - if ($PSCmdlet.ShouldProcess((Get-MemberId), 'Remove user group member')) { - if (Get-MemberId -isnot [array]) { - $membersToRemove += @(Get-MemberId) - } - else { - $membersToRemove += Get-MemberId - } - $payload = $membersToRemove -join ', ' - $body = "[$payload]" - } - - # WebAPI accepts max 100 accounts. Thus we send a request, and reset the `membersToRemove` - # in order to accept more members - if ($membersToRemove.Length -eq 100) { - Invoke-TeamViewerRestMethodInternal - $membersToRemove = @() - } - } - - End { - # A request needs to be send if there were less than 100 members - if ($membersToRemove.Length -gt 0) { - Invoke-TeamViewerRestMethodInternal - } - } -} - - - -function Remove-TeamViewerUserRole { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [Alias('Id')] - [object] - $UserRoleId - ) - - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles?userRoleId=$UserRoleId" - } - - Process { - if ($PSCmdlet.ShouldProcess($UserRoleId.ToString(), 'Remove User Role')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Delete ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Restart-TeamViewerService { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if ($PSCmdlet.ShouldProcess('TeamViewer service')) { - switch (Get-OperatingSystem) { - 'Windows' { - Restart-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon restart - } - } - } -} - - - -function Set-TeamViewerAccount { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('DisplayName')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $Password, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $OldPassword, - - [Parameter(ParameterSetName = 'ByParameters')] - [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] - [object] - $EmailLanguage, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($Name) { - $body['name'] = $Name - } - if ($Email) { - $body['email'] = $Email - } - if ($Password) { - if (-Not $OldPassword) { - $PSCmdlet.ThrowTerminatingError( - ("Old password required when attempting to change account password." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($OldPassword) - $body['oldpassword'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($EmailLanguage) { - $body['email_language'] = $EmailLanguage | Resolve-TeamViewerLanguage - } - } - 'ByProperties' { - @('name', 'email', 'password', 'oldpassword', 'email_language') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the account." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $resourceUri = "$(Get-TeamViewerApiUri)/account" - - if ($PSCmdlet.ShouldProcess("TeamViewer account")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -function Set-TeamViewerAPIUri { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [string]$NewUri, - [Parameter(Mandatory = $false)] - [bool]$Default - ) - - $config = [TeamViewerConfiguration]::GetInstance() - $PSDefaultParameterValues = @{'CmdletName:Default' = $true } - - if ($PSCmdlet.ShouldProcess('TeamViewer account')) { - if ($NewUri) { - $config.APIUri = $NewUri - Write-Output "TeamViewer API URL set to: $($config.APIUri)" - } - elseif ($Default) { - $config.APIUri = 'https://webapi.teamviewer.com/api/v1' - Write-Output "TeamViewer API URL set to: $($config.APIUri)" - } - } - -} - - - -function Set-TeamViewerDevice { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Default")] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerDeviceId } )] - [Alias("DeviceId")] - [Alias("Id")] - [object] - $Device, - - [Parameter(ParameterSetName = "ChangeGroup")] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(ParameterSetName = "ChangePolicy")] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId -AllowInherit -AllowNone } )] - [Alias("PolicyId")] - [object] - $Policy, - - [Parameter()] - [Alias("Alias")] - [string] - $Name, - - [Parameter()] - [string] - $Description, - - [Parameter()] - [securestring] - $Password - ) - Begin { - $body = @{} - - if ($Name) { - $body['alias'] = $Name - } - if ($Description) { - $body['description'] = $Description - } - if ($Password) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($Group) { - $body['groupid'] = $Group | Resolve-TeamViewerGroupId - } - if ($Policy) { - $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId -AllowNone -AllowInherit - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the device." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $deviceId = $Device | Resolve-TeamViewerDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($Device.ToString(), "Change device entry")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Set-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [Alias("Id")] - [object] - $Group, - - [Parameter(ParameterSetName = 'ByParameters')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias("PolicyId")] - [object] - $Policy, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - Begin { - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - $body['name'] = $Name - if ($Policy) { - $body['policy_id'] = $Policy | Resolve-TeamViewerPolicyId - } - } - 'ByProperties' { - @('name', 'policy_id') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the group." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $groupId = $Group | Resolve-TeamViewerGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, "Update group")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Set-TeamViewerManagedDevice { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias('DeviceId')] - [object] - $Device, - - [Alias('Alias')] - [string] - $Name, - - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias('PolicyId')] - [object] - $Policy, - - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId } )] - [Alias('ManagedGroupId')] - [object] - $ManagedGroup - ) - Begin { - $body = @{} - - if ($Name) { - $body['name'] = $Name - } - if ($Policy) { - $body['teamviewerPolicyId'] = $Policy | Resolve-TeamViewerPolicyId - } - elseif ($ManagedGroup) { - $body['managedGroupId'] = $ManagedGroup | Resolve-TeamViewerManagedGroupId - } - - if ($Policy -And $ManagedGroup) { - $PSCmdlet.ThrowTerminatingError( - ('The combination of parameters -Policy and -ManagedGroup is not allowed.' | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ('The given input does not change the managed device.' | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId" - - if ($PSCmdlet.ShouldProcess($Device.ToString(), 'Change managed device entry')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop | ` - Out-Null - } - } -} - - - -function Set-TeamViewerManagedGroup { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias('GroupId')] - [Alias('Id')] - [object] - $Group, - - [Parameter(ParameterSetName = 'ByParameters')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias('Policy')] - [object] - $PolicyId, - - [Parameter(ParameterSetName = 'ByParameters')] - [PolicyType] - $PolicyType, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - - Begin { - # Warning suppression doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($Name) { - $body['name'] = $Name - } - - if ($PolicyId -or $PolicyType) { - if (-not ($PolicyId -and $PolicyType)) { - $PSCmdlet.ThrowTerminatingError( - ('PolicyId and PolicyType must be specified together' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $body['policy'] = @{ - 'policy_id' = $PolicyId - 'policy_type' = $PolicyType - } - } - } - 'ByProperties' { - @('name') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } - - if ($Property.ContainsKey('policy_id') -or $Property.ContainsKey('policy_type')) { - if (-not ($Property.ContainsKey('policy_id') -and $Property.ContainsKey('policy_type'))) { - $PSCmdlet.ThrowTerminatingError( - ('PolicyId and PolicyType must be specified together' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $body['policy'] = @{ - 'policy_id' = $Property['policy_id'] - 'policy_type' = [PolicyType]$Property['policy_type'] - } - } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ('The given input does not change the managed group.' | ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - - Process { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId" - - if ($PSCmdlet.ShouldProcess($groupId, 'Update managed group')) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | Out-Null - } - } -} - - - -function Set-TeamViewerManager { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Device_ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [ValidateScript( { - if (($_.PSObject.TypeNames -contains 'TeamViewerPS.Manager') -And -Not $_.GroupId -And -Not $_.DeviceId) { - $PSCmdlet.ThrowTerminatingError( - ("Invalid manager object. Manager must be a group or device manager." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - $_ | Resolve-TeamViewerManagerId - })] - [Alias("ManagerId")] - [Alias("Id")] - [object] - $Manager, - - [Parameter(ParameterSetName = 'Device_ByParameters')] - [Parameter(ParameterSetName = 'Device_ByProperties')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedDeviceId } )] - [Alias("DeviceId")] - [object] - $Device, - - [Parameter(ParameterSetName = 'Group_ByParameters')] - [Parameter(ParameterSetName = 'Group_ByProperties')] - [ValidateScript( { $_ | Resolve-TeamViewerManagedGroupId })] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(ParameterSetName = 'Device_ByParameters')] - [Parameter(ParameterSetName = 'Group_ByParameters')] - [AllowEmptyCollection()] - [string[]] - $Permissions, - - [Parameter(Mandatory = $true, ParameterSetName = 'Device_ByProperties')] - [Parameter(Mandatory = $true, ParameterSetName = 'Group_ByProperties')] - [hashtable] - $Property - ) - Begin { - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch -Wildcard ($PSCmdlet.ParameterSetName) { - '*ByParameters' { - $body['permissions'] = @($Permissions) - } - '*ByProperties' { - @('permissions') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the manager." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - } - Process { - $deviceId = $null - $groupId = $null - if ($Manager.PSObject.TypeNames -contains 'TeamViewerPS.Manager') { - if ($Device -Or $Group) { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must not be specified if a [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - if ($Manager.DeviceId) { - $deviceId = $Manager.DeviceId - } - elseif ($Manager.GroupId) { - $groupId = $Manager.GroupId - } - } - elseif ($Device) { - $deviceId = $Device | Resolve-TeamViewerManagedDeviceId - } - elseif ($Group) { - $groupId = $Group | Resolve-TeamViewerManagedGroupId - } - else { - $PSCmdlet.ThrowTerminatingError( - ("Device or Group parameter must be specified if no [TeamViewerPS.Manager] object is given." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $managerId = $Manager | Resolve-TeamViewerManagerId - if ($deviceId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/$deviceId/managers/$managerId" - $processMessage = "Update managed device manager" - } - elseif ($groupId) { - $resourceUri = "$(Get-TeamViewerApiUri)/managed/groups/$groupId/managers/$managerId" - $processMessage = "Update managed group manager" - } - - if ($PSCmdlet.ShouldProcess($managerId, $processMessage)) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } - } -} - - - -function Set-TeamViewerPolicy { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerPolicyId } )] - [Alias('PolicyId')] - [object] - $Policy, - - [Parameter(ParameterSetName = 'ByParameters')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [object[]] - $Settings, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - # Warning suppresion doesn't seem to work. - # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 - $null = $Property - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($Name) { - $body['name'] = $Name - } - if ($Settings) { - $body['settings'] = $Settings - } - } - 'ByProperties' { - @('name', 'settings') | ` - Where-Object { $Property[$_] } | ` - ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ("The given input does not change the policy." | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $policyId = $Policy | Resolve-TeamViewerPolicyId - $resourceUri = "$(Get-TeamViewerApiUri)/teamviewerpolicies/$policyId" - - if ($PSCmdlet.ShouldProcess($policyId, "Update policy")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json -Depth 25))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - - -$global:TeamViewerProxyUriSet = $null - -function Set-TeamViewerPSProxy { - [CmdletBinding(SupportsShouldProcess =$true)] - param ( - [Parameter(Mandatory=$true)] - [Uri] - $ProxyUri - ) - - if($PSCmdlet.ShouldProcess($ProxyUri,"Sets proxy for WebAPI")){ - $global:TeamViewerProxyUriSet = $ProxyUri - $global:TeamViewerProxyUriRemoved = $false - $global:TeamViewerProxyUriRemoved | Out-Null - - [Environment]::SetEnvironmentVariable("TeamViewerProxyUri", $ProxyUri, "User") - - Write-Output "Proxy set to $TeamViewerProxyUriSet" - } -} - - - - -function Set-TeamViewerUser { - [CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'ByParameters')] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserId } )] - [Alias('UserId')] - [Alias('Id')] - [object] - $User, - - [Parameter(ParameterSetName = 'ByParameters')] - [boolean] - $Active, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('EmailAddress')] - [string] - $Email, - - [Parameter(ParameterSetName = 'ByParameters')] - [Alias('DisplayName')] - [string] - $Name, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $Password, - - [Parameter(ParameterSetName = 'ByParameters')] - [securestring] - $SsoCustomerIdentifier, - - [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] - [hashtable] - $Property - ) - - $body = @{} - switch ($PSCmdlet.ParameterSetName) { - 'ByParameters' { - if ($PSBoundParameters.ContainsKey('Active')) { - $body['active'] = $Active - } - if ($Email) { - $body['email'] = $Email - } - if ($Name) { - $body['name'] = $Name - } - if ($Password) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password) - $body['password'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - if ($SsoCustomerIdentifier) { - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SsoCustomerIdentifier) - $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) - [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null - } - } - 'ByProperties' { - @('active', 'email', 'name', 'password', 'sso_customer_id') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } - } - } - - if ($body.Count -eq 0) { - $PSCmdlet.ThrowTerminatingError( - ('The given input does not change the user.' | ` - ConvertTo-ErrorRecord -ErrorCategory InvalidArgument)) - } - - $userId = Resolve-TeamViewerUserId -User $User - $resourceUri = "$(Get-TeamViewerApiUri)/users/$userId" - - if ($PSCmdlet.ShouldProcess($userId, 'Update user profile')) { - Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Put -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) -WriteErrorTo $PSCmdlet | Out-Null - } -} - - - -function Set-TeamViewerUserGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserGroupId } )] - [Alias("UserGroupId")] - [Alias("Id")] - [object] - $UserGroup, - - [Parameter(Mandatory = $true)] - [Alias("UserGroupName")] - [string] - $Name - ) - Begin { - $id = $UserGroup | Resolve-TeamViewerUserGroupId - $resourceUri = "$(Get-TeamViewerApiUri)/usergroups/$id" - $body = @{ name = $Name } - } - Process { - if ($PSCmdlet.ShouldProcess($UserGroup.ToString(), "Change user group")) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - Write-Output ($response | ConvertTo-TeamViewerUserGroup) - } - } -} - - - - -function Set-TeamViewerUserRole { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true )] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [Alias('UserRoleName')] - [string] - $Name, - - [Parameter(Mandatory = $false)] - [AllowEmptyCollection()] - [object[]] - $Permissions, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerUserRoleId } )] - [Alias('UserRole')] - [object] - $UserRoleId - ) - Begin { - $resourceUri = "$(Get-TeamViewerApiUri)/userroles" - $body = @{ - Name = $Name - Permissions = @() - UserRoleId = $UserRoleId - - } - if ($Permissions) { - $body.Permissions = @($Permissions) - } - } - Process { - if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { - $response = Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Put ` - -ContentType 'application/json; charset=utf-8' ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet ` - -ErrorAction Stop - - $result = $response - Write-Output $result - } - } - -} - - - -function Start-TeamViewerService { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if ($PSCmdlet.ShouldProcess("TeamViewer service")) { - switch (Get-OperatingSystem) { - 'Windows' { - Start-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon start - } - } - } -} - - - -function Stop-TeamViewerService { - [CmdletBinding(SupportsShouldProcess = $true)] - param() - - if ($PSCmdlet.ShouldProcess("TeamViewer service")) { - switch (Get-OperatingSystem) { - 'Windows' { - Stop-Service -Name (Get-TeamViewerServiceName) - } - 'Linux' { - Invoke-ExternalCommand /opt/teamviewer/tv_bin/script/teamviewer daemon stop - } - } - } -} - - - -function Test-TeamViewerConnectivity { - param( - [Parameter()] - [switch] - $Quiet - ) - - $endpoints = @( - @{ Hostname = 'webapi.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'login.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'meeting.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'sso.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'download.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'configdl.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'get.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'go.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'client.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'feedbackservice.teamviewer.com'; TcpPort = 443; } - @{ Hostname = 'remotescriptingstorage.blob.core.windows.net'; TcpPort = 443; } - @{ Hostname = 'chatlivestorage.blob.core.windows.net'; TcpPort = 443; } - ) - 1..16 | ForEach-Object { - $endpoints += @{ Hostname = "router$_.teamviewer.com"; TcpPort = (5938, 443, 80) } - } - - $results = $endpoints | ForEach-Object { - $endpoint = $_ - $portSucceeded = $endpoint.TcpPort | Where-Object { - Write-Verbose "Checking endpoint $($endpoint.Hostname) on port $_" - Test-TcpConnection -Hostname $endpoint.Hostname -Port $_ - } | Select-Object -First 1 - $endpoint.Succeeded = [bool]$portSucceeded - $endpoint.TcpPort = if ($endpoint.Succeeded) { $portSucceeded } else { $endpoint.TcpPort } - return $endpoint - } - - if ($Quiet) { - ![bool]($results | Where-Object { -Not $_.Succeeded }) - } - else { - $results | ` - ForEach-Object { New-Object PSObject -Property $_ } | ` - Select-Object -Property Hostname, TcpPort, Succeeded | ` - Sort-Object Hostname - } -} - - - -function Test-TeamViewerInstallation { - if (Get-TeamViewerInstallationDirectory) { - return $true - } - else { - return $false - } -} - - - -function Unpublish-TeamViewerGroup { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true)] - [securestring] - $ApiToken, - - [Parameter(Mandatory = $true)] - [ValidateScript( { $_ | Resolve-TeamViewerGroupId } )] - [Alias("GroupId")] - [object] - $Group, - - [Parameter(Mandatory = $true)] - [Alias("UserId")] - [object[]] - $User - ) - - $groupId = $Group | Resolve-TeamViewerGroupId - $userIds = $User | Resolve-TeamViewerUserId - $resourceUri = "$(Get-TeamViewerApiUri)/groups/$groupId/unshare_group" - $body = @{users = @($userIds) } - - if ($PSCmdlet.ShouldProcess($userids, "Remove group share")) { - Invoke-TeamViewerRestMethod ` - -ApiToken $ApiToken ` - -Uri $resourceUri ` - -Method Post ` - -ContentType "application/json; charset=utf-8" ` - -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` - -WriteErrorTo $PSCmdlet | ` - Out-Null - } -} - - +$ModuleTypes = @( Get-ChildItem -Path "$PSScriptRoot/TeamViewerPS.Types.ps1" -ErrorAction SilentlyContinue ) +$PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -ErrorAction SilentlyContinue ) +$PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -ErrorAction SilentlyContinue ) +@($ModuleTypes + $PublicFunctions + $PrivateFunctions) | ForEach-Object { . $_.FullName } +Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * diff --git a/Docs/Help/Add-TeamViewerUserGroupToUserRole.md b/Docs/Help/Add-TeamViewerUserGroupToRole.md similarity index 100% rename from Docs/Help/Add-TeamViewerUserGroupToUserRole.md rename to Docs/Help/Add-TeamViewerUserGroupToRole.md diff --git a/Docs/Help/Get-TeamViewerUserRole.md b/Docs/Help/Get-TeamViewerRole.md similarity index 100% rename from Docs/Help/Get-TeamViewerUserRole.md rename to Docs/Help/Get-TeamViewerRole.md diff --git a/Docs/Help/New-TeamViewerUserRole.md b/Docs/Help/New-TeamViewerRole.md similarity index 100% rename from Docs/Help/New-TeamViewerUserRole.md rename to Docs/Help/New-TeamViewerRole.md diff --git a/Docs/Help/Remove-TeamViewerUserRole.md b/Docs/Help/Remove-TeamViewerRole.md similarity index 100% rename from Docs/Help/Remove-TeamViewerUserRole.md rename to Docs/Help/Remove-TeamViewerRole.md diff --git a/Docs/Help/Set-TeamViewerAPIUri.md b/Docs/Help/Set-TeamViewerAPIUri.md new file mode 100644 index 0000000..4a601a6 --- /dev/null +++ b/Docs/Help/Set-TeamViewerAPIUri.md @@ -0,0 +1,84 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerAPIUri.md +schema: 2.0.0 +--- + +# Set-TeamViewerAPIUri + +## SYNOPSIS + +Change uri of the TeamViewer web API for TeamViewerPS. + +## SYNTAX + +```powershell +Set-TeamViewerAPIUri [-NewUri ] +``` + +## DESCRIPTION + +Change uri of TeamViewer web API for TeamViewer internal testing purposes. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Set-TeamViewerAPIUri -NewUri 'www.example.com' +``` + +Sets the uri of the web API to `www.example.com`. + +### Example 2 + +```powershell +PS /> Set-TeamViewerAPIUri -Default $true +``` + +Sets the WebAPI for TeamViewerPS to the default value. + +## PARAMETERS + +### -NewUri + +Sets a specific uri to the web API for TeamViewerPS. + +```yaml +Type: String +Parameter Sets: None +Aliases: None + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Default + +Sets the web API for TeamViewerPS to the default value. + +```yaml +Type: Bool +Parameter Sets: None +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/Docs/Help/Set-TeamViewerUserRole.md b/Docs/Help/Set-TeamViewerRole.md similarity index 100% rename from Docs/Help/Set-TeamViewerUserRole.md rename to Docs/Help/Set-TeamViewerRole.md diff --git a/Tests/Private/Test-ManifestFile.Tests.ps1 b/Tests/Private/Test-ManifestFile.Tests.ps1 new file mode 100644 index 0000000..390257b --- /dev/null +++ b/Tests/Private/Test-ManifestFile.Tests.ps1 @@ -0,0 +1,48 @@ +BeforeAll { + $Script:Module_RootPath = (Resolve-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath '..\..')) + $Script:Module_FilePath = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets') -Filter '*.psm1' -File).FullName + $Script:Module_Name = (Split-Path -Path $Module_FilePath -Leaf).Replace('.psm1', '') + $Script:Module_ManifestFilePath = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets') -Filter '*.psd1' -File).FullName +} + +Context 'Test-ManifestFile' { + It 'Valid module manifest file' { + $Module_ManifestFilePath | Should -Exist + + { + $Script:Module_Manifest = Test-ModuleManifest -Path $Module_ManifestFilePath -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Valid manifest root module' { + $Module_Manifest.RootModule | Should -Be "$Module_Name.psm1" + } + + It 'Valid version check' { + $Module_Manifest.Version -as [Version] | Should -Not -BeNullOrEmpty + } + + It 'Valid manifest GUID' { + $Module_Manifest.Guid | Should -Be 'd4e57325-dfd9-4391-8259-ce81d2aa7d48' + } + + It 'Valid manifest author' { + $Module_Manifest.Author | Should -Be 'TeamViewer Germany GmbH' + } + + It 'Valid manifest company' { + $Module_Manifest.CompanyName | Should -Be 'TeamViewer Germany GmbH' + } + + It 'Valid manifest description' { + $Module_Manifest.Description | Should -BeLike "$Module_Name*" + } +} + +<# Context 'Import module' { + It "Module ($Module_Name) can be imported" { + $Module_FilePath | Should -Exist + + { Import-Module $Module_FilePath -Force } | Should Not Throw + } +} #> diff --git a/Tests/Private/Test-PowershellFilesValidity.Tests.ps1 b/Tests/Private/Test-PowershellFilesValidity.Tests.ps1 new file mode 100644 index 0000000..43a7e2e --- /dev/null +++ b/Tests/Private/Test-PowershellFilesValidity.Tests.ps1 @@ -0,0 +1,30 @@ +BeforeAll { + $Script:Module_RootPath = (Resolve-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath '..\..')) +} + +Context 'Test-PowershellFilesValidity' { + $TVPS_PSFiles = Get-ChildItem $Module_RootPath -Include *.ps1 -Recurse + + $Test_Case = $TVPS_PSFiles | ForEach-Object { + @{ + FilePath = $_.fullname + FileName = $_.Name + + } + } + + It 'Script should be a valid Powershell file' -TestCases $Test_Case { + param( + $FilePath + ) + + $FilePath | Should -Exist + + $Test_FileContent = Get-Content -Path $FilePath -ErrorAction Stop + + $Test_Error = $null + $null = [System.Management.Automation.PSParser]::Tokenize($Test_FileContent, [ref]$Test_Error) + + $Test_Error.Count | Should -Be 0 + } +} diff --git a/Tests/Private/Test-PrivateFunctions.Tests.ps1 b/Tests/Private/Test-PrivateFunctions.Tests.ps1 new file mode 100644 index 0000000..7684840 --- /dev/null +++ b/Tests/Private/Test-PrivateFunctions.Tests.ps1 @@ -0,0 +1,16 @@ +BeforeAll { + $Script:Module_RootPath = (Resolve-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath '..\..')) + $Script:Module_FilePath = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets') -Filter '*.psm1' -File).FullName + $Script:Module_Name = (Split-Path -Path $Module_FilePath -Leaf).Replace('.psm1', '') + $Script:Module_ManifestFilePath = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets') -Filter '*.psd1' -File).FullName + $Script:Module_PrivFunctionNames = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets\Private') -Filter '*.ps1' -File | Select-Object BaseName) +} + +Context 'Test-PrivateFunctions' { + + It 'Private functions not accessible from outside' { + foreach ($PrivFunction in $Module_PrivFunctionNames.BaseName) { + { . $PrivFunction } | Should -Throw + } + } +} diff --git a/Tests/Private/Test-PublicFunctions.Tests.ps1 b/Tests/Private/Test-PublicFunctions.Tests.ps1 new file mode 100644 index 0000000..df8a726 --- /dev/null +++ b/Tests/Private/Test-PublicFunctions.Tests.ps1 @@ -0,0 +1,28 @@ +BeforeAll { + $Script:Module_RootPath = (Resolve-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath '..\..')) + $Script:Module_FilePath = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets') -Filter '*.psm1' -File).FullName + $Script:Module_Name = (Split-Path -Path $Module_FilePath -Leaf).Replace('.psm1', '') + $Script:PublicFuncFiles = (Get-ChildItem -Path (Join-Path -Path $Module_RootPath -ChildPath 'Cmdlets\Public') -Filter '*.ps1' -File | Select-Object BaseName) + $Script:TestFilesDir = Join-Path -Path $Module_RootPath -ChildPath 'Tests\Public' + $Script:HelpFilesDir = Join-Path -Path $Module_RootPath -ChildPath 'Docs\Help' +} + +Describe 'Public Function File Checks' { + Context 'Comparing directories' { + It 'Function has a corresponding test file' { + foreach ($funcName in $PublicFuncFiles.BaseName ) { + $testFilePath = Join-Path -Path $TestFilesDir -ChildPath "$funcName.Tests.ps1" + Test-Path $testFilePath | Should -Be $true + } + } + } + + It 'Function has a corresponding help file' { + foreach ($funcName in $PublicFuncFiles.BaseName) { + $helpFilePath = Join-Path -Path $HelpFilesDir -ChildPath "$funcName.md" + Test-Path $helpFilePath | Should -Be $true + } + } +} + + diff --git a/Tests/Public/Invoke-TeamViewerPackageDownload.Tests.ps1 b/Tests/Public/Invoke-TeamViewerPackageDownload.Tests.ps1 new file mode 100644 index 0000000..8baff65 --- /dev/null +++ b/Tests/Public/Invoke-TeamViewerPackageDownload.Tests.ps1 @@ -0,0 +1,6 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Invoke-TeamViewerPakcageDownload.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } +} diff --git a/Tests/Public/Remove-TeamViewerUserFromRole.ps1 b/Tests/Public/Remove-TeamViewerUserFromRole.Tests.ps1 similarity index 91% rename from Tests/Public/Remove-TeamViewerUserFromRole.ps1 rename to Tests/Public/Remove-TeamViewerUserFromRole.Tests.ps1 index aab15fd..22f0de1 100644 --- a/Tests/Public/Remove-TeamViewerUserFromRole.ps1 +++ b/Tests/Public/Remove-TeamViewerUserFromRole.Tests.ps1 @@ -14,8 +14,8 @@ BeforeAll { $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @{ - UserIds = @($testAccount) - RoleId = $testRoleId + UserIds = @($testAccount) + UserRoleId = $testRoleId } } } @@ -42,7 +42,7 @@ Describe 'Remove-TeamViewerUserFromRole' { foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.RoleId | Should -Be $testRoleId + $body.UserRoleId | Should -Be $testRoleId } It 'Should accept pipeline input' { @@ -55,6 +55,6 @@ Describe 'Remove-TeamViewerUserFromRole' { foreach ($id in $testAccount) { $body.UserIds | Should -Contain $id } - $body.RoleId | Should -Be $testRoleId + $body.UserRoleId | Should -Be $testRoleId } } diff --git a/Tests/Public/Set-TeamViewerAPIUri.Tests.ps1 b/Tests/Public/Set-TeamViewerAPIUri.Tests.ps1 new file mode 100644 index 0000000..379197f --- /dev/null +++ b/Tests/Public/Set-TeamViewerAPIUri.Tests.ps1 @@ -0,0 +1,6 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Set-TeamViewerApiUri.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } +} From d380b2b08acd2084e19f2ccefd5421f2b608c32b Mon Sep 17 00:00:00 2001 From: karthickgandhiTV <139859343+karthickgandhiTV@users.noreply.github.com> Date: Fri, 10 Nov 2023 10:57:24 +0100 Subject: [PATCH 100/110] Role parameters added (#66) * Role parameters added * Documentation update * Documentation update --- Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 | 5 +++ Cmdlets/Public/New-TeamViewerUser.ps1 | 23 +++++++++-- Cmdlets/Public/Set-TeamViewerUser.ps1 | 20 ++++++++- Docs/Help/New-TeamViewerUser.md | 29 ++++++++++++- Docs/Help/Set-TeamViewerUser.md | 43 +++++++++++++++++++- 5 files changed, 113 insertions(+), 7 deletions(-) diff --git a/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 index 988ff4a..653e492 100644 --- a/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 +++ b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 @@ -15,6 +15,11 @@ function ConvertTo-TeamViewerUser { Name = $InputObject.name Email = $InputObject.email } + if ($InputObject.userRoleId) { + $properties += @{ + RoleId = $InputObject.userRoleId + } + } if ($PropertiesToLoad -Eq 'All') { $properties += @{ diff --git a/Cmdlets/Public/New-TeamViewerUser.ps1 b/Cmdlets/Public/New-TeamViewerUser.ps1 index 2381fe0..ab1750d 100644 --- a/Cmdlets/Public/New-TeamViewerUser.ps1 +++ b/Cmdlets/Public/New-TeamViewerUser.ps1 @@ -31,15 +31,24 @@ function New-TeamViewerUser { [Parameter()] [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] [cultureinfo] - $Culture + $Culture, + + [Parameter()] + [ValidateScript({ $_ | Resolve-TeamViewerRoleId })] + [object] + $RoleId, + + [Parameter()] + [switch] + $IgnorePredefinedRole ) if (-Not $Culture) { try { - $Culture = Get-Culture + $Culture = Get-Culture } catch { - $Culture = 'en' + $Culture = 'en' } } @@ -61,6 +70,14 @@ function New-TeamViewerUser { [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null } + if($RoleId){ + $body['userRoleId'] = $RoleId | Resolve-TeamViewerRoleId + } + + if($IgnorePredefinedRole){ + $body['ignorePredefinedRole'] = $true + } + $resourceUri = "$(Get-TeamViewerApiUri)/users" if ($PSCmdlet.ShouldProcess("$Name <$Email>", 'Create user')) { $response = Invoke-TeamViewerRestMethod -ApiToken $ApiToken -Uri $resourceUri -Method Post -ContentType 'application/json; charset=utf-8' ` diff --git a/Cmdlets/Public/Set-TeamViewerUser.ps1 b/Cmdlets/Public/Set-TeamViewerUser.ps1 index 835b905..dcda9d7 100644 --- a/Cmdlets/Public/Set-TeamViewerUser.ps1 +++ b/Cmdlets/Public/Set-TeamViewerUser.ps1 @@ -36,7 +36,19 @@ function Set-TeamViewerUser { [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] [hashtable] - $Property + $Property, + + [Parameter()] + [Alias('AssignRole')] + [ValidateScript({ $_ | Resolve-TeamViewerRoleId })] + [string[]] + $AssignRoleId, + + [Parameter()] + [Alias('UnassignRole')] + [ValidateScript({ $_ | Resolve-TeamViewerRoleId })] + [string[]] + $UnassignRoleId ) $body = @{} @@ -61,6 +73,12 @@ function Set-TeamViewerUser { $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null } + if($AssignRoleId){ + $body['assignUserRoleIds'] = @($AssignRoleId) + } + if($UnassignRoleId){ + $body['unassignUserRoleIds'] = @($UnassignRoleId) + } } 'ByProperties' { @('active', 'email', 'name', 'password', 'sso_customer_id') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } diff --git a/Docs/Help/New-TeamViewerUser.md b/Docs/Help/New-TeamViewerUser.md index 0125200..4d5230e 100644 --- a/Docs/Help/New-TeamViewerUser.md +++ b/Docs/Help/New-TeamViewerUser.md @@ -16,14 +16,14 @@ Create a new TeamViewer company user. ### WithPassword (Default) ```powershell -New-TeamViewerUser -ApiToken -Email -Name -Password +New-TeamViewerUser -ApiToken -Email -Name -Password [-RoleId ][-IgnorePredefinedRole ] [-SsoCustomerIdentifier ] [-Culture ] [-WhatIf] [-Confirm] [] ``` ### WithoutPassword ```powershell -New-TeamViewerUser -ApiToken -Email -Name [-WithoutPassword] +New-TeamViewerUser -ApiToken -Email -Name [-WithoutPassword][-IgnorePredefinedRole ] [-SsoCustomerIdentifier ] [-Culture ] [-WhatIf] [-Confirm] [] ``` @@ -50,6 +50,15 @@ PS /> New-TeamViewerUser -Email 'test@example.test' -Name 'Test User' -WithoutPa Create a new user with the given email address and name. It will be created without a password. The user must reset the password through the TeamViewer web page. +### Example 3 + +```powershell +PS /> New-TeamViewerUser -Email 'test@example.test' -Name 'Test User' -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' +``` + +Create a new user with the given email address and name. +The Role with RoleID `9b465ea2-2f75-4101-a057-58a81ed0e57b` will be assigned. + ## PARAMETERS ### -ApiToken @@ -166,6 +175,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RoleId + +Role assigned to the user. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: None + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -WhatIf Shows what would happen if the cmdlet runs. diff --git a/Docs/Help/Set-TeamViewerUser.md b/Docs/Help/Set-TeamViewerUser.md index 4d359ba..083b7ee 100644 --- a/Docs/Help/Set-TeamViewerUser.md +++ b/Docs/Help/Set-TeamViewerUser.md @@ -16,7 +16,7 @@ Change properties of a TeamViewer company user. ### ByParameters (Default) ```powershell -Set-TeamViewerUser -ApiToken -User [-Active ] [-Email ] +Set-TeamViewerUser -ApiToken -User [-Active ] [-Email ][-AssignRoleId ][-UnassignRoleId ] [-Name ] [-Password ] [-SsoCustomerIdentifier ] [-WhatIf] [-Confirm] [] ``` @@ -66,6 +66,15 @@ PS /> Set-TeamViewerUser -UserId 'u1234' -SsoCustomerIdentifier $ssoCustomerIden Do the SSO activation step for the given user. This can also be used to repair a possibly broken SSO login token for that user. +### Example 5 + +```powershell +PS /> Set-TeamViewerUser -User 'u1234' -Name 'New user name' -AssignRoleId 'dd1cb784-bd1e-4056-a60b-3764ffe69e35' +-UnassignRoleId 'a6776890-d687-4c70-b180-9b563f15d1ab' +``` + +Assign and unassign Roles of the user `u1234` + ## PARAMETERS ### -Active @@ -164,6 +173,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -AssignRoleId + +Role assigned to the user. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: AssignRole + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UnassignRoleId + +Role unassigned from the user. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: UnassignRole + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Property Change policy information using a hashtable object. From 018f690018e0b69990993866c419de469b393923 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV <139859343+karthickgandhiTV@users.noreply.github.com> Date: Sat, 11 Nov 2023 12:47:42 +0100 Subject: [PATCH 101/110] Documentation update (#67) --- Docs/Help/New-TeamViewerUser.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Docs/Help/New-TeamViewerUser.md b/Docs/Help/New-TeamViewerUser.md index 4d5230e..1c7dd81 100644 --- a/Docs/Help/New-TeamViewerUser.md +++ b/Docs/Help/New-TeamViewerUser.md @@ -191,6 +191,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -IgnorePredefinedRole + +Ignore Predefined Role from being assigned. + +```yaml +Type: switch +Parameter Sets: (All) +Aliases: None + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -WhatIf Shows what would happen if the cmdlet runs. From f7b31d160f3d5c379a59a88dfcb1d60468b7866d Mon Sep 17 00:00:00 2001 From: karthickgandhiTV <139859343+karthickgandhiTV@users.noreply.github.com> Date: Wed, 22 Nov 2023 10:32:13 +0100 Subject: [PATCH 102/110] Permissions added for user management (#68) --- CHANGELOG.md | 3 ++- Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 | 1 + Cmdlets/Public/Get-TeamViewerUser.ps1 | 11 ++++++++-- Cmdlets/Public/New-TeamViewerUser.ps1 | 5 +++++ Cmdlets/Public/Set-TeamViewerUser.ps1 | 11 +++++++++- Docs/Help/Get-TeamViewerUser.md | 20 ++++++++++++++++++- Docs/Help/New-TeamViewerUser.md | 20 +++++++++++++++++-- Docs/Help/Set-TeamViewerUser.md | 21 ++++++++++++++++++-- Tests/Public/Get-TeamViewerUser.Tests.ps1 | 6 ++++++ Tests/Public/Set-TeamViewerUser.Tests.ps1 | 18 +++++++++++++++-- 10 files changed, 105 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eef9c3..ca3fb0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,13 +11,14 @@ - Adds `Export-TeamViewerSystemInformation` to create zip file for support. - Adds `Set-TeamViewerPSProxy` and `Remove-TeamViewerPSProxy` to set proxy to access WebAPI. - Adds `Get-TeamViewerInstallationDirectory` to return installation directory. +- Adds `Get-TeamViewerCustomModuleId` to return custom module ID. +- Adds `Get-TeamViewerLogFilePath` to return log file paths for different logs present. - Adds `Remove-TeamViewerPolicyFromManagedDevice` to remove policies from managed devices. ### Changed - Extends `Invoke-TeamViewerPackageDownload` with MSI package type. - Removes `-RemovePolicy` switch from `Set-TeamViewerManagedDevice`. -- Removes `-Permissions` switch from `Get-TeamViewerUser`, `New-TeamViewerUser` and `Remove-TeamViewerUser`. - Modifies general module folder structure. ### Fixed diff --git a/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 index 653e492..5269bdd 100644 --- a/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 +++ b/Cmdlets/Private/ConvertTo-TeamViewerUser.ps1 @@ -23,6 +23,7 @@ function ConvertTo-TeamViewerUser { if ($PropertiesToLoad -Eq 'All') { $properties += @{ + Permissions = $InputObject.permissions -split ',' Active = $InputObject.active LastAccessDate = $InputObject.last_access_date | ConvertTo-DateTime } diff --git a/Cmdlets/Public/Get-TeamViewerUser.ps1 b/Cmdlets/Public/Get-TeamViewerUser.ps1 index c5d34cd..d611bfe 100644 --- a/Cmdlets/Public/Get-TeamViewerUser.ps1 +++ b/Cmdlets/Public/Get-TeamViewerUser.ps1 @@ -20,6 +20,10 @@ function Get-TeamViewerUser { [string[]] $Email, + [Parameter(ParameterSetName = "FilteredList")] + [string[]] + $Permissions, + [Parameter()] [ValidateSet('All', 'Minimal')] $PropertiesToLoad = 'All' @@ -28,9 +32,9 @@ function Get-TeamViewerUser { $parameters = @{ } switch ($PropertiesToLoad) { 'All' { - $parameters.full_list = $true + $parameters.full_list = $true } - 'Minimal' { + 'Minimal' { } } @@ -49,6 +53,9 @@ function Get-TeamViewerUser { if ($Email) { $parameters['email'] = ($Email -join ',') } + if ($Permissions) { + $parameters['permissions'] = ($Permissions -join ',') + } } } diff --git a/Cmdlets/Public/New-TeamViewerUser.ps1 b/Cmdlets/Public/New-TeamViewerUser.ps1 index ab1750d..f6a7ef6 100644 --- a/Cmdlets/Public/New-TeamViewerUser.ps1 +++ b/Cmdlets/Public/New-TeamViewerUser.ps1 @@ -28,6 +28,10 @@ function New-TeamViewerUser { [securestring] $SsoCustomerIdentifier, + [Parameter()] + [array] + $Permissions, + [Parameter()] [ValidateScript( { $_ | Resolve-TeamViewerLanguage } )] [cultureinfo] @@ -56,6 +60,7 @@ function New-TeamViewerUser { email = $Email name = $Name language = $Culture | Resolve-TeamViewerLanguage + permissions = $Permissions -join ',' } if ($Password -And -Not $WithoutPassword) { diff --git a/Cmdlets/Public/Set-TeamViewerUser.ps1 b/Cmdlets/Public/Set-TeamViewerUser.ps1 index dcda9d7..87454b0 100644 --- a/Cmdlets/Public/Set-TeamViewerUser.ps1 +++ b/Cmdlets/Public/Set-TeamViewerUser.ps1 @@ -34,6 +34,10 @@ function Set-TeamViewerUser { [securestring] $SsoCustomerIdentifier, + [Parameter(ParameterSetName = 'ByParameters')] + [array] + $Permissions, + [Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')] [hashtable] $Property, @@ -73,6 +77,9 @@ function Set-TeamViewerUser { $body['sso_customer_id'] = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) | Out-Null } + if ($Permissions) { + $body['permissions'] = $Permissions -join ',' + } if($AssignRoleId){ $body['assignUserRoleIds'] = @($AssignRoleId) } @@ -81,7 +88,9 @@ function Set-TeamViewerUser { } } 'ByProperties' { - @('active', 'email', 'name', 'password', 'sso_customer_id') | Where-Object { $Property[$_] } | ForEach-Object { $body[$_] = $Property[$_] } + @('active', 'email', 'name', 'password', 'sso_customer_id', 'permissions') | ` + Where-Object { $Property[$_] } | ` + ForEach-Object { $body[$_] = $Property[$_] } } } diff --git a/Docs/Help/Get-TeamViewerUser.md b/Docs/Help/Get-TeamViewerUser.md index ee439cf..162d76a 100644 --- a/Docs/Help/Get-TeamViewerUser.md +++ b/Docs/Help/Get-TeamViewerUser.md @@ -16,7 +16,8 @@ Retrieve users of a TeamViewer company. ### FilteredList (Default) ```powershell -Get-TeamViewerUser -ApiToken [-Name ] [-Email ] [-PropertiesToLoad ] [] +Get-TeamViewerUser -ApiToken [-Name ] [-Email ] [-Permissions ] + [-PropertiesToLoad ] [] ``` ### ByUserId @@ -123,6 +124,23 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Permissions + +Optional permissions filter that can be used to only list users that have +certain permissions. Multiple values can be given. + +```yaml +Type: String[] +Parameter Sets: FilteredList +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -PropertiesToLoad Can be used to retrieve all available properties of a user or just a stripped-down minimal set of user properties. diff --git a/Docs/Help/New-TeamViewerUser.md b/Docs/Help/New-TeamViewerUser.md index 1c7dd81..e792a68 100644 --- a/Docs/Help/New-TeamViewerUser.md +++ b/Docs/Help/New-TeamViewerUser.md @@ -17,14 +17,14 @@ Create a new TeamViewer company user. ```powershell New-TeamViewerUser -ApiToken -Email -Name -Password [-RoleId ][-IgnorePredefinedRole ] - [-SsoCustomerIdentifier ] [-Culture ] [-WhatIf] [-Confirm] [] + [-SsoCustomerIdentifier ][-Permissions ][-Culture ] [-WhatIf] [-Confirm] [] ``` ### WithoutPassword ```powershell New-TeamViewerUser -ApiToken -Email -Name [-WithoutPassword][-IgnorePredefinedRole ] - [-SsoCustomerIdentifier ] [-Culture ] [-WhatIf] [-Confirm] [] + [-SsoCustomerIdentifier ][-Permissions ][-Culture ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -157,6 +157,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Permissions + +Optional list of permissions to give to the new user. + +```yaml +Type: Array +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -SsoCustomerIdentifier Optional TeamViewer SSO customer identifier. If given, the user will be created diff --git a/Docs/Help/Set-TeamViewerUser.md b/Docs/Help/Set-TeamViewerUser.md index 083b7ee..94bc09d 100644 --- a/Docs/Help/Set-TeamViewerUser.md +++ b/Docs/Help/Set-TeamViewerUser.md @@ -17,7 +17,7 @@ Change properties of a TeamViewer company user. ```powershell Set-TeamViewerUser -ApiToken -User [-Active ] [-Email ][-AssignRoleId ][-UnassignRoleId ] - [-Name ] [-Password ] [-SsoCustomerIdentifier ] [-WhatIf] [-Confirm] [] + [-Name ] [-Password ] [-SsoCustomerIdentifier ] [-Permissions ] [-WhatIf] [-Confirm] [] ``` ### ByProperties @@ -173,6 +173,23 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Permissions + +Updated set of permissions of the company user. +Please see the TeamViewer API documentation for a list of valid values. + +```yaml +Type: Array +Parameter Sets: ByParameters +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -AssignRoleId Role assigned to the user. @@ -209,7 +226,7 @@ Accept wildcard characters: False Change policy information using a hashtable object. Valid hashtable keys are: -`active`, `email`, `name`, `password`, `sso_customer_id` +`active`, `email`, `name`, `password`, `sso_customer_id`, `permissions` ```yaml Type: Hashtable diff --git a/Tests/Public/Get-TeamViewerUser.Tests.ps1 b/Tests/Public/Get-TeamViewerUser.Tests.ps1 index 0ceb008..56cb093 100644 --- a/Tests/Public/Get-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Get-TeamViewerUser.Tests.ps1 @@ -52,6 +52,12 @@ Describe 'Get-TeamViewerUser' { $Body -And $Body['email'] -eq 'user1@unit.test,user2@unit.test' } } + It 'Should allow to filter by permissions' { + Get-TeamViewerUser -ApiToken $testApiToken -Permissions 'p1', 'p2', 'p3' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $Body -And $Body['permissions'] -eq 'p1,p2,p3' } + } + It 'Should allow to retrieve all properties' { Get-TeamViewerUser -ApiToken $testApiToken -PropertiesToLoad 'All' diff --git a/Tests/Public/Set-TeamViewerUser.Tests.ps1 b/Tests/Public/Set-TeamViewerUser.Tests.ps1 index b652c34..aee71a8 100644 --- a/Tests/Public/Set-TeamViewerUser.Tests.ps1 +++ b/Tests/Public/Set-TeamViewerUser.Tests.ps1 @@ -33,7 +33,15 @@ Describe 'Set-TeamViewerUser' { $testPassword = 'Test1234' | ConvertTo-TestPassword $testSsoCustomerId = 'SsoTest' | ConvertTo-TestPassword - Set-TeamViewerUser -ApiToken $testApiToken -User 'u1234' -Name 'Updated User Name' -Email 'foo@bar.com' -Password $testPassword -SsoCustomerIdentifier $testSsoCustomerId -Active $false + Set-TeamViewerUser ` + -ApiToken $testApiToken ` + -User 'u1234' ` + -Name 'Updated User Name' ` + -Email 'foo@bar.com' ` + -Password $testPassword ` + -SsoCustomerIdentifier $testSsoCustomerId ` + -Permissions 'ManageAdmins', 'ManageUsers' ` + -Active $false $mockArgs.Body | Should -Not -BeNullOrEmpty $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json @@ -41,15 +49,20 @@ Describe 'Set-TeamViewerUser' { $body.email | Should -Be 'foo@bar.com' $body.password | Should -Be 'Test1234' $body.sso_customer_id | Should -Be 'SsoTest' + $body.permissions | Should -Be 'ManageAdmins,ManageUsers' $body.active | Should -BeFalse } It 'Should accept user properties as hashtable' { - Set-TeamViewerUser -ApiToken $testApiToken -User 'u1234' -Property @{ + Set-TeamViewerUser ` + -ApiToken $testApiToken ` + -User 'u1234' ` + -Property @{ name = 'Updated User Name' email = 'foo@bar.com' password = 'Test1234' sso_customer_id = 'SsoTest' + permissions = 'ManageAdmins,ManageUsers' active = $false } @@ -59,6 +72,7 @@ Describe 'Set-TeamViewerUser' { $body.email | Should -Be 'foo@bar.com' $body.password | Should -Be 'Test1234' $body.sso_customer_id | Should -Be 'SsoTest' + $body.permissions | Should -Be 'ManageAdmins,ManageUsers' $body.active | Should -BeFalse } From d09d781bb55d76213e9de17d0cda1152c265d430 Mon Sep 17 00:00:00 2001 From: "christian.jaeckle" Date: Wed, 22 Nov 2023 11:22:53 +0100 Subject: [PATCH 103/110] Adds real release date to change log --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca3fb0d..89d9470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## 2.0.0 (2023-10-xx) +## 2.0.0 (2023-11-22) ### Added From ee697c3547a6dffcfb35bae56a873d8aa05fb0f9 Mon Sep 17 00:00:00 2001 From: karthickgandhiTV <139859343+karthickgandhiTV@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:24:26 +0100 Subject: [PATCH 104/110] User management param update (#69) * Permissions added for user management * Fix output folder for Publish Production Param --- .github/workflows/publish_production.yml | 2 +- .gitignore | 2 +- Build/New-Package.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 301c8bb..417efaf 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -28,4 +28,4 @@ jobs: shell: pwsh run: | $ProgressPreference='SilentlyContinue' - Publish-Module -Path $env:GITHUB_WORKSPACE/Build/Output/ -NuGetApiKey $env:NUGET_APIKEY_PRODUCTION + Publish-Module -Path $env:GITHUB_WORKSPACE/Build/TeamViewerPS/ -NuGetApiKey $env:NUGET_APIKEY_PRODUCTION diff --git a/.gitignore b/.gitignore index 9585e52..38af4d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/Build/Output +/Build/TeamViewerPS diff --git a/Build/New-Package.ps1 b/Build/New-Package.ps1 index ceb2da3..51bf0fc 100644 --- a/Build/New-Package.ps1 +++ b/Build/New-Package.ps1 @@ -2,7 +2,7 @@ param( [Parameter()] - [string]$Build_OutputPath = "$(Resolve-Path "$PSScriptRoot\..")\Build\Output" + [string]$Build_OutputPath = "$(Resolve-Path "$PSScriptRoot\..")\Build\TeamViewerPS" ) $Repo_RootPath = Resolve-Path -Path "$PSScriptRoot\.." From 60526390c6ee4d9730c8b3cf0c8f9ac263ac921d Mon Sep 17 00:00:00 2001 From: Hasmik Barseghyan Date: Wed, 30 Oct 2024 17:09:30 +0400 Subject: [PATCH 105/110] TEAM-59155 Add TeamViewerSsoInclusion script for importing users to SSO Inclusion list Adding help file for TeamViewerSsoInclusion Adding unit tests for Add-TeamViewerSsoInclusion --- Cmdlets/Public/Add-TeamViewerSsoInclusion.ps1 | 53 +++++++ Docs/Help/Add-TeamViewerSsoInclusion.md | 137 ++++++++++++++++++ .../Add-TeamViewerSsoInclusion.Tests.ps1 | 73 ++++++++++ 3 files changed, 263 insertions(+) create mode 100644 Cmdlets/Public/Add-TeamViewerSsoInclusion.ps1 create mode 100644 Docs/Help/Add-TeamViewerSsoInclusion.md create mode 100644 Tests/Public/Add-TeamViewerSsoInclusion.Tests.ps1 diff --git a/Cmdlets/Public/Add-TeamViewerSsoInclusion.ps1 b/Cmdlets/Public/Add-TeamViewerSsoInclusion.ps1 new file mode 100644 index 0000000..eb314e0 --- /dev/null +++ b/Cmdlets/Public/Add-TeamViewerSsoInclusion.ps1 @@ -0,0 +1,53 @@ +function Add-TeamViewerSsoInclusion { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken, + + [Parameter(Mandatory = $true)] + [ValidateScript( { $_ | Resolve-TeamViewerSsoDomainId } )] + [Alias("Domain")] + [object] + $DomainId, + + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [string[]] + $Email + ) + Begin { + $id = $DomainId | Resolve-TeamViewerSsoDomainId + $resourceUri = "$(Get-TeamViewerApiUri)/ssoDomain/$id/inclusion" + $emailsToAdd = @() + $null = $ApiToken + + function Invoke-RequestInternal { + $body = @{ + emails = @($emailsToAdd) + } + Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Post ` + -ContentType "application/json; charset=utf-8" ` + -Body ([System.Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json))) ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop | ` + Out-Null + } + } + Process { + if ($PSCmdlet.ShouldProcess($Email, "Add SSO inclusion")) { + $emailsToAdd += $Email + } + if ($emailsToAdd.Length -eq 100) { + Invoke-RequestInternal + $emailsToAdd = @() + } + } + End { + if ($emailsToAdd.Length -gt 0) { + Invoke-RequestInternal + } + } +} \ No newline at end of file diff --git a/Docs/Help/Add-TeamViewerSsoInclusion.md b/Docs/Help/Add-TeamViewerSsoInclusion.md new file mode 100644 index 0000000..3dd3e2c --- /dev/null +++ b/Docs/Help/Add-TeamViewerSsoInclusion.md @@ -0,0 +1,137 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Add-TeamViewerSsoInclusion.md +schema: 2.0.0 +--- + +# Add-TeamViewerSsoInclusion + +## SYNOPSIS + +Add emails to the inclusion list of a TeamViewer Single Sign-On domain. + +## SYNTAX + +```powershell +Add-TeamViewerSsoInclusion [-ApiToken] [-DomainId] [-Email] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION + +Add emails to the inclusion list of a TeamViewer Single Sign-On domain. +Only accounts with these email addresses will be able to login via Single +Sign-On. + +## EXAMPLES + +### Example 1 + +```powershell +PS /> Add-TeamViewerSsoInclusion -DomainId '45e0d050-15e6-4fcb-91b2-ea4f20fe2085' -Email 'user@example.test' +``` + +Adds the email address '' to the inclusion list of the given +domain. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +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 +``` + +### -DomainId + +Object that can be used to identify the SSO domain to add inclusion entries to. +This can either be the SSO domain ID (as string or GUID) or a SsoDomain +object that has been received using the `Get-TeamViewerSsoDomain` function. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Domain + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Email + +List of emails addresses to add to the inclusion list. +The emails must be of the same email domain as the SSO domain, otherwise the +command will fail. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByValue) +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 +``` + +### 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 + +[Get-TeamViewerSsoDomain](Get-TeamViewerSsoDomain.md) \ No newline at end of file diff --git a/Tests/Public/Add-TeamViewerSsoInclusion.Tests.ps1 b/Tests/Public/Add-TeamViewerSsoInclusion.Tests.ps1 new file mode 100644 index 0000000..0df3d83 --- /dev/null +++ b/Tests/Public/Add-TeamViewerSsoInclusion.Tests.ps1 @@ -0,0 +1,73 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Add-TeamViewerSsoInclusion.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + $testDomainId = '45e0d050-15e6-4fcb-91b2-ea4f20fe2085' + $null = $testDomainId + + Mock Get-TeamViewerApiUri { '//unit.test' } + $mockArgs = @{} + Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body } +} + +Describe 'Add-TeamViewerSsoInclusion' { + It 'Should call the correct API endpoint' { + Add-TeamViewerSsoInclusion ` + -ApiToken $testApiToken ` + -DomainId $testDomainId ` + -Email 'foo@example.test' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/ssoDomain/$testDomainId/inclusion" -And ` + $Method -eq 'Post' } + } + + It 'Should add the given emails to the inclusion list' { + Add-TeamViewerSsoInclusion ` + -ApiToken $testApiToken ` + -DomainId $testDomainId ` + -Email 'foo@example.test', 'bar@example.test' + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.emails | Should -Contain 'foo@example.test' + $body.emails | Should -Contain 'bar@example.test' + } + + It 'Should accept pipeline input' { + @('foo@example.test', 'bar@example.test') | Add-TeamViewerSsoInclusion ` + -ApiToken $testApiToken ` + -DomainId $testDomainId + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.emails | Should -Contain 'foo@example.test' + $body.emails | Should -Contain 'bar@example.test' + } + + It 'Should handle domain objects as input' { + $testDomain = @{DomainId = $testDomainId; DomainName = 'test managed group' } | ConvertTo-TeamViewerSsoDomain + Add-TeamViewerSsoInclusion ` + -ApiToken $testApiToken ` + -Domain $testDomain ` + -Email 'foo@example.test' + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "//unit.test/ssoDomain/$testDomainId/inclusion" -And ` + $Method -eq 'Post' } + } + + It 'Should create bulks' { + $testAddresses = @() + 1..250 | ForEach-Object { $testAddresses += "foo$_@example.test" } + $testAddresses | Add-TeamViewerSsoInclusion ` + -ApiToken $testApiToken ` + -DomainId $testDomainId + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 3 -Scope It + $mockArgs.Body | Should -Not -BeNullOrEmpty + $body = [System.Text.Encoding]::UTF8.GetString($mockArgs.Body) | ConvertFrom-Json + $body.emails | Should -HaveCount 50 + } +} From aa73394ac6e9598bd27fe294182c4eb1bcef7ed4 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 14 Nov 2024 08:59:05 +0100 Subject: [PATCH 106/110] Update change log for 2.0.1. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d9470..2276c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 2.0.1 (2024-11-14) + +### Added +- Add-TeamViewerSsoInclusion command to add SSO Inclusion list items. + ## 2.0.0 (2023-11-22) ### Added From 67c9fd124a5aaf1bc99fb2814350f98d9969ab7e Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 14 Nov 2024 09:12:55 +0100 Subject: [PATCH 107/110] Update version manifest to 2.0.1. --- Cmdlets/TeamViewerPS.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index d2e0437..af47ae1 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '2.0.0' + ModuleVersion = '2.0.1' # Supported PSEditions. # CompatiblePSEditions = @() From f8a07e8184c7800df877943a129fb4d0ecd17396 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 14 Nov 2024 09:19:46 +0100 Subject: [PATCH 108/110] Update version manifest to 2.0.2. --- Cmdlets/TeamViewerPS.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index af47ae1..facd771 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '2.0.1' + ModuleVersion = '2.0.2' # Supported PSEditions. # CompatiblePSEditions = @() @@ -18,7 +18,7 @@ CompanyName = 'TeamViewer Germany GmbH' # Copyright statement for this module. - Copyright = '(c) 2021-2023 TeamViewer Germany GmbH. All rights reserved.' + Copyright = '(c) 2021-2024 TeamViewer Germany GmbH. All rights reserved.' # Description of the functionality provided by this module. Description = 'TeamViewerPS allows to interact with the TeamViewer Web API as well as a locally installed TeamViewer client.' From a16999826a9d31bdf85172134ed402c66c8f15e8 Mon Sep 17 00:00:00 2001 From: Achilleas Mitos Date: Fri, 15 Nov 2024 11:40:57 +0200 Subject: [PATCH 109/110] Added Get-TeamViewerCompanyManagedDevice cmdlet - Added new cmdlet that calls into the appropriate WebApi endpoint and retrieves all company-managed devices of the company associated with the ApiToken - Added unit tests for the new cmdlet - Updated documentation to include the new cmdlet - Bumped the module's minor version Needed for JIRA task TEAM-60324. --- CHANGELOG.md | 6 ++ .../Get-TeamViewerCompanyManagedDevice.ps1 | 23 ++++++ Cmdlets/TeamViewerPS.psd1 | 2 +- .../Get-TeamViewerCompanyManagedDevice.md | 73 +++++++++++++++++++ Docs/TeamViewerPS.md | 2 + ...t-TeamViewerCompanyManagedDevice.Tests.ps1 | 66 +++++++++++++++++ 6 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 Cmdlets/Public/Get-TeamViewerCompanyManagedDevice.ps1 create mode 100644 Docs/Help/Get-TeamViewerCompanyManagedDevice.md create mode 100644 Tests/Public/Get-TeamViewerCompanyManagedDevice.Tests.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2276c94..b775873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 2.1.0 (2024-11-15) + +### Added + +- Adds `Get-TeamViewerCompanyManagedDevice` to return all company-managed devices. + ## 2.0.1 (2024-11-14) ### Added diff --git a/Cmdlets/Public/Get-TeamViewerCompanyManagedDevice.ps1 b/Cmdlets/Public/Get-TeamViewerCompanyManagedDevice.ps1 new file mode 100644 index 0000000..a1f31c9 --- /dev/null +++ b/Cmdlets/Public/Get-TeamViewerCompanyManagedDevice.ps1 @@ -0,0 +1,23 @@ +function Get-TeamViewerCompanyManagedDevice { + param( + [Parameter(Mandatory = $true)] + [securestring] + $ApiToken + ) + + $resourceUri = "$(Get-TeamViewerApiUri)/managed/devices/company" + $parameters = @{} + + do { + $response = Invoke-TeamViewerRestMethod ` + -ApiToken $ApiToken ` + -Uri $resourceUri ` + -Method Get ` + -Body $parameters ` + -WriteErrorTo $PSCmdlet ` + -ErrorAction Stop + + $parameters.paginationToken = $response.nextPaginationToken + Write-Output ($response.resources | ConvertTo-TeamViewerManagedDevice) + } while ($parameters.paginationToken) +} diff --git a/Cmdlets/TeamViewerPS.psd1 b/Cmdlets/TeamViewerPS.psd1 index facd771..78813a9 100644 --- a/Cmdlets/TeamViewerPS.psd1 +++ b/Cmdlets/TeamViewerPS.psd1 @@ -3,7 +3,7 @@ RootModule = 'TeamViewerPS.psm1' # Version number of this module. - ModuleVersion = '2.0.2' + ModuleVersion = '2.1.0' # Supported PSEditions. # CompatiblePSEditions = @() diff --git a/Docs/Help/Get-TeamViewerCompanyManagedDevice.md b/Docs/Help/Get-TeamViewerCompanyManagedDevice.md new file mode 100644 index 0000000..cac46a4 --- /dev/null +++ b/Docs/Help/Get-TeamViewerCompanyManagedDevice.md @@ -0,0 +1,73 @@ +--- +external help file: TeamViewerPS-help.xml +Module Name: TeamViewerPS +online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerCompanyManagedDevice.md +schema: 2.0.0 +--- + +# Get-TeamViewerCompanyManagedDevice + +## SYNOPSIS + +Retrieves TeamViewer company-managed devices. Requires an API Token with company admin permissions. + +## SYNTAX + +### List (Default) + +```powershell +Get-TeamViewerCompanyManagedDevice -ApiToken [] +``` + +## DESCRIPTION + +Retrieves company-managed devices of the company that is associated with the API access token. + +## EXAMPLES + +### Example 1 + +```powershell + +PS /> Get-TeamViewerCompanyManagedDevice +``` + +List all company-managed devices of this company. + +## PARAMETERS + +### -ApiToken + +The TeamViewer API access token. Needs to have company admin permissions to successfully retrieve the devices. + +```yaml +Type: SecureString +Parameter Sets: (All) +Aliases: + +Required: True +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 + +## NOTES + +## RELATED LINKS + +[Get-TeamViewerManagedDevice](Get-TeamViewerManagedDevice.md) + +[Get-TeamViewerManagedGroup](Get-TeamViewerManagedGroup.md) + +[Get-TeamViewerManagementId](Get-TeamViewerManagementId.md) diff --git a/Docs/TeamViewerPS.md b/Docs/TeamViewerPS.md index fe0e802..6275976 100644 --- a/Docs/TeamViewerPS.md +++ b/Docs/TeamViewerPS.md @@ -133,6 +133,8 @@ The following functions are available in this category: [`Get-TeamViewerManagedGroup`](Help/Get-TeamViewerManagedGroup.md) +[`Get-TeamViewerCompanyManagedDevice`](Help/Get-TeamViewerCompanyManagedDevice.md) + [`Get-TeamViewerManagementId`](Help/Get-TeamViewerManagementId.md) [`Get-TeamViewerManager`](Help/Get-TeamViewerManager.md) diff --git a/Tests/Public/Get-TeamViewerCompanyManagedDevice.Tests.ps1 b/Tests/Public/Get-TeamViewerCompanyManagedDevice.Tests.ps1 new file mode 100644 index 0000000..53b5563 --- /dev/null +++ b/Tests/Public/Get-TeamViewerCompanyManagedDevice.Tests.ps1 @@ -0,0 +1,66 @@ +BeforeAll { + . "$PSScriptRoot\..\..\Cmdlets\Public\Get-TeamViewerCompanyManagedDevice.ps1" + + @(Get-ChildItem -Path "$PSScriptRoot\..\..\Cmdlets\Private\*.ps1") | ` + ForEach-Object { . $_.FullName } + + $testApiToken = [securestring]@{} + $null = $testApiToken + + Mock Get-TeamViewerApiUri { '//unit.test' } +} + +Describe 'Get-TeamViewerCompanyManagedDevice' { + Context 'AllDevices' { + BeforeAll { + Mock Invoke-TeamViewerRestMethod { @{ + nextPaginationToken = $null + resources = @( + @{ id = 'ae222e9d-a665-4cea-85b7-d4a3a08a5e35'; name = 'test company-managed device 1' }, + @{ id = '6cbfcfb2-a929-4987-a91b-89e2945412cf'; name = 'test company-managed device 2' }, + @{ id = '99a87bed-3d60-46f2-a869-b7e67a6bf2c8'; name = 'test company-managed device 3' } + ) + } } + } + + It 'Should call the correct API endpoint to list company-managed devices' { + Get-TeamViewerCompanyManagedDevice -ApiToken $testApiToken + + $base_test_path = '//unit.test' + $desired_endpoint = 'managed/devices/company' + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { + $ApiToken -eq $testApiToken -And ` + $Uri -eq "$base_test_path/$desired_endpoint" -And ` + $Method -eq 'Get' } + } + + It 'Should return ManagedDevice objects' { + $result = Get-TeamViewerCompanyManagedDevice -ApiToken $testApiToken + $result | Should -HaveCount 3 + $result[0].PSObject.TypeNames | Should -Contain 'TeamViewerPS.ManagedDevice' + } + + It 'Should fetch consecutive pages' { + Mock Invoke-TeamViewerRestMethod { @{ + nextPaginationToken = 'abc' + resources = @( + @{ id = 'ae222e9d-a665-4cea-85b7-d4a3a08a5e35'; name = 'test company-managed device 1' }, + @{ id = '6cbfcfb2-a929-4987-a91b-89e2945412cf'; name = 'test company-managed device 2' }, + @{ id = '99a87bed-3d60-46f2-a869-b7e67a6bf2c8'; name = 'test company-managed device 3' } + ) + } } + Mock Invoke-TeamViewerRestMethod { @{ + nextPaginationToken = $null + resources = @( + @{ id = '76e699b7-2559-4202-bf7b-c6af6929aa15'; name = 'test company-managed device 4' } + ) + } } -ParameterFilter { $Body -And $Body['paginationToken'] -eq 'abc' } + + $result = Get-TeamViewerCompanyManagedDevice -ApiToken $testApiToken + $result | Should -HaveCount 4 + + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 2 -Scope It + } + } +} From 60caf284a0b4161fd2cef16e4372417418b3023f Mon Sep 17 00:00:00 2001 From: Achilleas Mitos Date: Fri, 15 Nov 2024 15:28:25 +0200 Subject: [PATCH 110/110] Corrected the 2.0.1 changelog entry to 2.0.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b775873..4baeed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Adds `Get-TeamViewerCompanyManagedDevice` to return all company-managed devices. -## 2.0.1 (2024-11-14) +## 2.0.2 (2024-11-14) ### Added - Add-TeamViewerSsoInclusion command to add SSO Inclusion list items.