Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User management param update #70

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/Build/Output
/Build/TeamViewerPS
5 changes: 3 additions & 2 deletions Build/New-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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\.."
Expand Down Expand Up @@ -32,8 +32,9 @@ Write-Verbose "Found $($PublicFunctions.Count) public function files."

# Create help from markdown
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
Copy-Item -Path (Join-Path -Path $Repo_RootPath -ChildPath 'Docs\about_TeamViewerPS.md') -Destination (Join-Path -Path $Build_OutputPath -ChildPath 'en-US\TeamViewerPS.md')


# Create module manifest
Write-Verbose 'Creating module manifest...'
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Cmdlets/Private/ConvertTo-TeamViewerUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 9 additions & 2 deletions Cmdlets/Public/Get-TeamViewerUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function Get-TeamViewerUser {
[string[]]
$Email,

[Parameter(ParameterSetName = "FilteredList")]
[string[]]
$Permissions,

[Parameter()]
[ValidateSet('All', 'Minimal')]
$PropertiesToLoad = 'All'
Expand All @@ -28,9 +32,9 @@ function Get-TeamViewerUser {
$parameters = @{ }
switch ($PropertiesToLoad) {
'All' {
$parameters.full_list = $true
$parameters.full_list = $true
}
'Minimal' {
'Minimal' {
}
}

Expand All @@ -49,6 +53,9 @@ function Get-TeamViewerUser {
if ($Email) {
$parameters['email'] = ($Email -join ',')
}
if ($Permissions) {
$parameters['permissions'] = ($Permissions -join ',')
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions Cmdlets/Public/New-TeamViewerUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function New-TeamViewerUser {
[securestring]
$SsoCustomerIdentifier,

[Parameter()]
[array]
$Permissions,

[Parameter()]
[ValidateScript( { $_ | Resolve-TeamViewerLanguage } )]
[cultureinfo]
Expand Down Expand Up @@ -56,6 +60,7 @@ function New-TeamViewerUser {
email = $Email
name = $Name
language = $Culture | Resolve-TeamViewerLanguage
permissions = $Permissions -join ','
}

if ($Password -And -Not $WithoutPassword) {
Expand Down
11 changes: 10 additions & 1 deletion Cmdlets/Public/Set-TeamViewerUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ function Set-TeamViewerUser {
[securestring]
$SsoCustomerIdentifier,

[Parameter(ParameterSetName = 'ByParameters')]
[array]
$Permissions,

[Parameter(Mandatory = $true, ParameterSetName = 'ByProperties')]
[hashtable]
$Property,
Expand Down Expand Up @@ -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)
}
Expand All @@ -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[$_] }
}
}

Expand Down
20 changes: 19 additions & 1 deletion Docs/Help/Get-TeamViewerUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Retrieve users of a TeamViewer company.
### FilteredList (Default)

```powershell
Get-TeamViewerUser -ApiToken <SecureString> [-Name <String>] [-Email <String[]>] [-PropertiesToLoad <Object>] [<CommonParameters>]
Get-TeamViewerUser -ApiToken <SecureString> [-Name <String>] [-Email <String[]>] [-Permissions <String[]>]
[-PropertiesToLoad <Object>] [<CommonParameters>]
```

### ByUserId
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 18 additions & 2 deletions Docs/Help/New-TeamViewerUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Create a new TeamViewer company user.

```powershell
New-TeamViewerUser -ApiToken <SecureString> -Email <String> -Name <String> -Password <SecureString> [-RoleId <String>][-IgnorePredefinedRole <switch>]
[-SsoCustomerIdentifier <SecureString>] [-Culture <CultureInfo>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-SsoCustomerIdentifier <SecureString>][-Permissions <Array>][-Culture <CultureInfo>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### WithoutPassword

```powershell
New-TeamViewerUser -ApiToken <SecureString> -Email <String> -Name <String> [-WithoutPassword][-IgnorePredefinedRole <switch>]
[-SsoCustomerIdentifier <SecureString>] [-Culture <CultureInfo>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-SsoCustomerIdentifier <SecureString>][-Permissions <Array>][-Culture <CultureInfo>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions Docs/Help/Set-TeamViewerUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Change properties of a TeamViewer company user.

```powershell
Set-TeamViewerUser -ApiToken <SecureString> -User <Object> [-Active <Boolean>] [-Email <String>][-AssignRoleId <String[]>][-UnassignRoleId <String[]>]
[-Name <String>] [-Password <SecureString>] [-SsoCustomerIdentifier <SecureString>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-Name <String>] [-Password <SecureString>] [-SsoCustomerIdentifier <SecureString>] [-Permissions <Array>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ByProperties
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading