├── .gitattributes
├── .gitignore
├── .vscode
├── launch.json
└── tasks.json
├── Build.PSDeploy.ps1
├── Build.Psake.ps1
├── CHANGELOG.md
├── LICENSE
├── Posh-Teamviewer
├── Posh-Teamviewer.psd1
├── Posh-Teamviewer.psm1
├── Private
│ ├── Get-TeamviewerChoice.ps1
│ ├── Get-TeamviewerDeviceProperty.ps1
│ └── Resolve-TeamviewerConfigPath.ps1
├── Public
│ ├── Connect-Teamviewer.ps1
│ ├── Initialize-Teamviewer.ps1
│ ├── Set-TeamviewerAccessToken.ps1
│ ├── Set-TeamviewerDeviceList.ps1
│ └── Update-TeamviewerDevice.ps1
└── en-US
│ └── Posh-Teamviewer-help.xml
├── README.md
├── Tests
├── Connect-Teamviewer.Tests.ps1
├── Files
│ ├── api.key
│ └── salt.rnd
├── Get-TeamviewerDeviceProperty.Tests.ps1
├── Initialize-Teamviewer.Tests.ps1
├── Module.Help.Tests.ps1
├── Module.Links.Tests.ps1
├── Resolve-TeamviewerConfigPath.Tests.ps1
├── Set-TeamviewerAccessToken.Tests.ps1
├── Set-TeamviewerDeviceList.Tests.ps1
└── Update-TeamviewerDevice.Tests.ps1
├── appveyor.yml
├── docs
├── Commands
│ ├── Connect-Teamviewer.md
│ ├── Initialize-Teamviewer.md
│ ├── Set-TeamviewerAccessToken.md
│ ├── Set-TeamviewerDeviceList.md
│ └── Update-TeamviewerDevice.md
├── Images
│ └── SetAccessToken.gif
├── Setup
│ └── Getting-Started.md
└── index.md
└── mkdocs.yml
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Syncthing
2 | ~syncthing~*.tmp
3 |
4 | Release/
5 | TeamViewer_API_Documentation.pdf
6 |
7 | # Windows image file caches
8 | Thumbs.db
9 | ehthumbs.db
10 |
11 | # OSX
12 | .DS_Store
13 | .AppleDouble
14 | .LSOverride
15 | .Spotlight-V100
16 | .Trashes
17 | ._*
18 | .DocumentRevisions-V100
19 | .fseventsd
20 | .TemporaryItems
21 | .VolumeIcon.icns
22 |
23 | # Folder config file
24 | Desktop.ini
25 | picasa.ini
26 |
27 | # Office Temp Files
28 | ~$*
29 |
30 | # Powershell Studio
31 | *.psbuild
32 | *.psproj
33 | *.psprojs
34 | *.MainForm.psf
35 | *.TempPoint.psd1
36 | *.TempPoint.psm1
37 | *.TempPoint.ps1
38 | *.pss
39 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "PowerShell",
6 | "type": "PowerShell",
7 | "request": "launch",
8 | "program": "${file}",
9 | "args": [],
10 | "cwd": "${file}"
11 | },
12 | {
13 | "name": "PowerShell x86",
14 | "type": "PowerShell x86",
15 | "request": "launch",
16 | "program": "${file}",
17 | "args": [],
18 | "cwd": "${file}"
19 | }
20 | ]
21 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // A task runner that invokes Pester to run all Pester tests under the
2 | // current workspace folder.
3 |
4 | // NOTE: This Test task runner requires an updated version of Pester (>=3.4.0)
5 | // in order for the problemMatcher to find failed test information (message, line, file).
6 | // If you don't have that version, you can update Pester from the PowerShell Gallery
7 | // with this command:
8 | //
9 | // PS C:\> Update-Module Pester
10 | //
11 | // If that gives an error like:
12 | // "Module 'Pester' was not installed by using Install-Module, so it cannot be updated."
13 | // then execute:
14 | //
15 | // PS C:\> Install-Module Pester -Scope CurrentUser -Force
16 | //
17 |
18 | // NOTE: The Clean, Build and Publish tasks require PSake. PSake can be installed
19 | // from the PowerShell Gallery with this command:
20 | //
21 | // PS C:\> Install-Module PSake -Scope CurrentUser -Force
22 | //
23 |
24 | // Available variables which can be used inside of strings.
25 | // ${workspaceRoot}: the root folder of the team
26 | // ${file}: the current opened file
27 | // ${fileBasename}: the current opened file's basename
28 | // ${fileDirname}: the current opened file's dirname
29 | // ${fileExtname}: the current opened file's extension
30 | // ${cwd}: the current working directory of the spawned process
31 | {
32 | "version": "0.1.0",
33 |
34 | // Start PowerShell
35 | "command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
36 |
37 | // The command is a shell script
38 | "isShellCommand": true,
39 |
40 | // Show the output window always
41 | "showOutput": "always",
42 |
43 | "args": [
44 | "-NoProfile",
45 | "-ExecutionPolicy", "Bypass"
46 | ],
47 |
48 | // Associate with test task runner
49 | "tasks": [
50 | {
51 | "taskName": "Default",
52 | "suppressTaskName": true,
53 | "showOutput": "always",
54 | "args": [
55 | "Write-Host 'Invoking PSake...'; Invoke-PSake build.psake.ps1 -taskList Default;",
56 | "Invoke-Command { Write-Host 'Completed Clean task in task runner.' }"
57 | ]
58 | },
59 | {
60 | "taskName": "?",
61 | "suppressTaskName": true,
62 | "showOutput": "always",
63 | "args": [
64 | "Write-Host 'Invoking PSake...'; Invoke-PSake build.psake.ps1 -taskList ?;",
65 | "Invoke-Command { Write-Host 'Completed Clean task in task runner.' }"
66 | ]
67 | },
68 | {
69 | "taskName": "Build",
70 | "suppressTaskName": true,
71 | "isBuildCommand": true,
72 | "showOutput": "always",
73 | "args": [
74 | "Write-Host 'Starting Build'; Invoke-PSake build.psake.ps1 -taskList Build;",
75 | "Invoke-Command { Write-Host 'Completed Build task in task runner.' }"
76 | ]
77 | },
78 | {
79 | "taskName": "Publish",
80 | "suppressTaskName": true,
81 | "showOutput": "always",
82 | "args": [
83 | "Write-Host 'Invoking PSake...'; Invoke-PSake build.psake.ps1 -taskList Publish;",
84 | "Invoke-Command { Write-Host 'Completed Publish task in task runner.' }"
85 | ]
86 | },
87 | {
88 | "taskName": "Test",
89 | "suppressTaskName": true,
90 | "isTestCommand": true,
91 | "showOutput": "always",
92 | "args": [
93 | "Write-Host 'Invoking Pester...';Import-Module Pester; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true};",
94 | "Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
95 | ],
96 | "problemMatcher": [
97 | {
98 | "owner": "powershell",
99 | "fileLocation": ["absolute"],
100 | "severity": "error",
101 | "pattern": [
102 | {
103 | "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
104 | "message": 1
105 | },
106 | {
107 | "regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$",
108 | "file": 1,
109 | "line": 2
110 | }
111 | ]
112 | }
113 | ]
114 | }
115 | ]
116 | }
117 |
--------------------------------------------------------------------------------
/Build.PSDeploy.ps1:
--------------------------------------------------------------------------------
1 | Deploy Posh-Teamviewer {
2 |
3 | By PlatyPS {
4 | FromSource "$BHProjectPath\docs\Commands"
5 | To "$BHProjectPath\Posh-Teamviewer\en-US"
6 | Tagged Help
7 | WithOptions @{
8 | Force = $true
9 | }
10 | }
11 |
12 | By FileSystem {
13 | FromSource $ENV:BHProjectName
14 | To "$home\Documents\WindowsPowerShell\Modules\Posh-Teamviewer"
15 | Tagged Prod, Module, Local
16 | WithOptions @{
17 | Mirror = $true
18 | }
19 | WithPostScript {
20 | Import-Module -Name Posh-Teamviewer -Force
21 | }
22 | }
23 |
24 | By PSGalleryModule {
25 | FromSource $ENV:BHProjectName
26 | To PSGallery
27 | Tagged PSGallery
28 | WithOptions @{
29 | ApiKey = $ENV:NugetApiKey
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Build.Psake.ps1:
--------------------------------------------------------------------------------
1 | Task default -depends Deploy
2 |
3 | Properties {
4 | Set-BuildEnvironment
5 | $ErrorActionPreference = 'Stop'
6 |
7 | $ProjectRoot = $ENV:BHProjectPath
8 | $ProjectName = $ENV:BHProjectName
9 |
10 | if(-not $ProjectRoot) { [ValidateNotNullOrEmpty()]$ProjectRoot = $Psake.build_script_dir }
11 | if(-not $ProjectName) { [ValidateNotNullOrEmpty()]$ProjectName = (Get-Item $PSScriptRoot\*.psd1)[0].BaseName }
12 |
13 | $Timestamp = Get-date -uformat "%Y%m%d-%H%M%S"
14 | $PSVersion = $PSVersionTable.PSVersion.Major
15 | $TestFile = "TestResults_PS$PSVersion`_$TimeStamp.xml"
16 | $lines = '----------------------------------------------------------------------'
17 |
18 | $Verbose = @{}
19 | if ($ENV:BHCommitMessage -match "!verbose")
20 | {
21 | $Verbose = @{Verbose = $True}
22 | }
23 | }
24 |
25 |
26 | Task Init {
27 | Set-Location $ProjectRoot
28 | "$lines`nBuild System Details:"
29 |
30 | Get-Item ENV:BH*
31 | "`n"
32 | }
33 |
34 |
35 | Task Analyze -depends Init {
36 | "$lines`n`n`tSTATUS: Scanning for PSScriptAnalyzer Errors"
37 |
38 | $ScanResults = Invoke-ScriptAnalyzer -Path "$ProjectRoot\$ProjectName" -Recurse -Severity Error
39 |
40 | If ($ScanResults.count -gt 0)
41 | {
42 | Throw "Failed PSScriptAnalyzer Tests"
43 | }
44 | }
45 |
46 |
47 | Task Help -depends Analyze {
48 | "$lines`n`n`tSTATUS: Building Module Help"
49 |
50 | Remove-Module $ProjectName -ErrorAction SilentlyContinue
51 | Import-Module "$ProjectRoot\$ProjectName\$ProjectName.psd1"
52 |
53 | Try
54 | {
55 | New-ExternalHelp 'docs\Commands' -OutputPath "$ProjectName\en-US" -Force -ErrorAction Stop
56 | Import-Module "$ProjectRoot\$ProjectName\$ProjectName.psd1" -Force
57 | }
58 | Catch
59 | {
60 | Throw
61 | }
62 | }
63 |
64 |
65 | Task Test -depends Help {
66 | "$lines`n`n`tSTATUS: Testing with PowerShell $PSVersion"
67 |
68 | $TestResults = Invoke-Pester -Path $ProjectRoot\Tests -PassThru -PesterOption @{IncludeVSCodeMarker=$true} -OutputFormat NUnitXml -OutputFile "$ProjectRoot\$TestFile" -EnableExit -Strict
69 |
70 | If($ENV:BHBuildSystem -eq 'AppVeyor')
71 | {
72 | (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)","$ProjectRoot\$TestFile" )
73 | }
74 |
75 | Remove-Item "$ProjectRoot\$TestFile" -Force -ErrorAction SilentlyContinue
76 |
77 | if ($TestResults.FailedCount -gt 0)
78 | {
79 | Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed"
80 | }
81 | "`n"
82 | }
83 |
84 |
85 | Task Build -depends Test {
86 |
87 | if ($ENV:BHBuildSystem -eq 'Unknown')
88 | {
89 | "$lines`n`n`tSTATUS: Building Local Module"
90 |
91 | Try
92 | {
93 | Invoke-PSDeploy @Verbose -Tags Local -Force
94 | }
95 | Catch
96 | {
97 | Throw
98 | }
99 | }
100 | }
101 |
102 |
103 | Task Deploy -Depends Build {
104 |
105 | if ($ENV:BHBuildSystem -ne 'Unknown' -and $ENV:BHBranchName -eq "master" -and $ENV:BHCommitMessage -match '!deploy')
106 | {
107 | "$lines`n`n`tSTATUS: Publishing to PSGallery"
108 |
109 | Try
110 | {
111 | Invoke-PSDeploy @Verbose -Force -Tags 'PSGallery'
112 | }
113 | Catch
114 | {
115 | Throw
116 | }
117 | }
118 | else
119 | {
120 | "Skipping deployment: To deploy, ensure that...`n" +
121 | "`t* You are in a known build system (Current: $ENV:BHBuildSystem)`n" +
122 | "`t* You are committing to the master branch (Current: $ENV:BHBranchName) `n" +
123 | "`t* Your commit message includes !deploy (Current: $ENV:BHCommitMessage)"
124 | }
125 | }
126 |
127 |
128 | Task ? -description 'Lists the available tasks' {
129 | "Available tasks:"
130 | $psake.context.Peek().tasks.Keys | Sort
131 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Posh-Teamviewer Release History
2 |
3 | ## 1.0.1
4 | ### 06/10/2016
5 |
6 | - AccessToken parameters now only support [SecureString].
7 | - The Access token is now kept as a [SecureString] when loaded into the Session and is not converted to plaintext until needed to contact API.
8 |
9 | ## 1.0.0
10 | ### 06/09/2016
11 |
12 | - Initial release
13 | - Commands:
14 | - Connect-Teamviewer, Initialize-Teamviewer, Update-TeamviewerDevice, Set-TeamviewerAccessToken, Set-TeamviewerDeviceList
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Brandon Padgett
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Posh-Teamviewer/Posh-Teamviewer.psd1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gerane/Posh-Teamviewer/17629621e107dc41fe4dd9d432dc7712779f467b/Posh-Teamviewer/Posh-Teamviewer.psd1
--------------------------------------------------------------------------------
/Posh-Teamviewer/Posh-Teamviewer.psm1:
--------------------------------------------------------------------------------
1 | $Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue)
2 | $Private = @(Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue)
3 | $Script:ModuleRoot = $PSScriptRoot
4 |
5 | Foreach ($import in @($Public + $Private))
6 | {
7 | Try
8 | {
9 | . $import.fullname
10 | }
11 | Catch
12 | {
13 | Write-Error -Message "Failed to import function $($import.fullname): $_"
14 | }
15 | }
16 |
17 | # Removing Editor Commands until VS Code Supports SecureStrings
18 | # if ($psEditor)
19 | # {
20 | # Register-EditorCommand `
21 | # -Name "Posh-Teamviewer.ConnectDevice" `
22 | # -DisplayName "Connect to Teamviewer Device" `
23 | # -SuppressOutput `
24 | # -ScriptBlock {
25 | # param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
26 | # Connect-Teamviewer
27 | # }
28 |
29 | # Register-EditorCommand `
30 | # -Name "Posh-Teamviewer.SetDeviceList" `
31 | # -DisplayName "Set Teamviewer Device List Variable" `
32 | # -SuppressOutput `
33 | # -ScriptBlock {
34 | # param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
35 | # Set-TeamviewerDeviceList
36 | # }
37 |
38 | # Register-EditorCommand `
39 | # -Name "Posh-Teamviewer.InitializeTeamviewer" `
40 | # -DisplayName "Initialize Teamviewer" `
41 | # -SuppressOutput `
42 | # -ScriptBlock {
43 | # param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
44 | # Initialize-Teamviewer
45 | # }
46 | # }
47 |
48 | Export-ModuleMember -Function $Public.Basename
--------------------------------------------------------------------------------
/Posh-Teamviewer/Private/Get-TeamviewerChoice.ps1:
--------------------------------------------------------------------------------
1 | function Get-TeamviewerChoice
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [System.String]$Message = 'There were multiple matches',
7 |
8 | [Parameter(Mandatory=$true)]
9 | [ValidateNotNullOrEmpty()]
10 | [System.String[]]$Choices,
11 |
12 | [System.Int32]$DefaultChoice = 0,
13 |
14 | [System.String]$Title = "Please Select a Device Name"
15 | )
16 |
17 | Begin
18 | {
19 |
20 | }
21 |
22 | Process
23 | {
24 | Try
25 | {
26 | $ChoiceList = [System.Management.Automation.Host.ChoiceDescription[]] @($Choices)
27 | $Selection = $host.ui.PromptForChoice($Title, $Message, $ChoiceList, $DefaultChoice)
28 | }
29 | catch
30 | {
31 | throw $Error[0]
32 | }
33 |
34 | Return $Selection
35 | }
36 |
37 | End
38 | {
39 |
40 | }
41 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/Private/Get-TeamviewerDeviceProperty.ps1:
--------------------------------------------------------------------------------
1 | function Get-TeamviewerDeviceProperty
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'remotecontrol_id')]
4 | param
5 | (
6 | [Parameter(Mandatory=$true)]
7 | [string]$ComputerName,
8 |
9 | [Parameter(ParameterSetName = 'device_id')]
10 | [switch]$device_id,
11 |
12 | [Parameter(ParameterSetName = 'remotecontrol_id')]
13 | [switch]$remotecontrol_id,
14 |
15 | [Parameter(ParameterSetName = 'description')]
16 | [switch]$description
17 |
18 | )
19 |
20 | Begin
21 | {
22 | Write-Verbose -Message 'Starting: Get Teamviewer Device Property'
23 |
24 | if (!(Test-Path variable:Global:TeamviewerDeviceList ) -and !($DeviceList))
25 | {
26 | throw 'No Teamviewer Access Token has been specified or set. Use Set-TeamviewerAccessToken to set your AccessToken or Initialize-Teamviewer to load Teamviewer Global Variables.'
27 | }
28 | elseif ((Test-Path variable:Global:TeamviewerDeviceList ) -and !($DeviceList))
29 | {
30 | $DeviceList = $Global:TeamviewerDeviceList
31 | }
32 | }
33 |
34 | Process
35 | {
36 | $Property = $PSCmdlet.ParameterSetName
37 | Write-Verbose -Message "Device Property: [$($Property)]"
38 |
39 | $Devices = $DeviceList.devices | Where-Object { $_.'alias' -like "*$ComputerName*" }
40 |
41 | if ($Devices.count -eq 0)
42 | {
43 | Throw "No Device found for [$ComputerName]"
44 | }
45 | elseif ($Devices.count -gt '1')
46 | {
47 | Write-Verbose -Message "Multiple Names Matched, Prompting User for selection."
48 |
49 | $Selection = Get-TeamviewerChoice -Choices $Devices.alias
50 | $Device = $Devices[$Selection]
51 |
52 | $DeviceProperty = $Device.$Property
53 | }
54 | else
55 | {
56 | $DeviceProperty = $Devices.$Property
57 | }
58 | Write-Verbose -Message "Device [$($Property)] is [$($DeviceProperty)]"
59 |
60 | Return $DeviceProperty
61 | }
62 |
63 | End
64 | {
65 |
66 | }
67 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/Private/Resolve-TeamviewerConfigPath.ps1:
--------------------------------------------------------------------------------
1 | function Resolve-TeamviewerConfigPath
2 | {
3 | [CmdletBinding()]
4 | [OutputType([String])]
5 | param()
6 |
7 | Begin
8 | {
9 |
10 | }
11 |
12 | Process
13 | {
14 | Write-Verbose -Message 'Resolving Teamviewer Config Path'
15 | $Global:TeamviewerConfigPath = "$env:APPDATA\Teamviewer"
16 |
17 | Write-Verbose -Message "Teamviewer Config Path: $($Global:TeamviewerConfigPath)"
18 | Return $Global:TeamviewerConfigPath
19 | }
20 |
21 | End
22 | {
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/Public/Connect-Teamviewer.ps1:
--------------------------------------------------------------------------------
1 | # .ExternalHelp Teamviewer-Help.xml
2 | function Connect-Teamviewer
3 | {
4 | [CmdletBinding(DefaultParameterSetName = 'List')]
5 | param
6 | (
7 | [Parameter(ParameterSetName = 'List', Mandatory=$true)]
8 | [Parameter(ParameterSetName = 'Update', Mandatory=$true)]
9 | [string[]]$ComputerName,
10 |
11 | [Parameter(ParameterSetName = 'List', Mandatory=$true)]
12 | [Parameter(ParameterSetName = 'Update', Mandatory=$true)]
13 | [securestring]$Password,
14 |
15 | [Parameter(ParameterSetName = 'Update', Mandatory=$false)]
16 | [Switch]$UpdateDeviceList,
17 |
18 | [Parameter(ParameterSetName = 'Update', Mandatory=$false)]
19 | [securestring]$AccessToken
20 | )
21 |
22 | Begin
23 | {
24 | Write-Verbose -Message 'Starting: Connect to Teamviewer Device'
25 |
26 | if ($PSBoundParameters.ContainsKey('UpdateDeviceList'))
27 | {
28 | if (!(Test-Path variable:Global:TeamviewerAccessToken ) -and !($AccessToken))
29 | {
30 | throw 'No Teamviewer Access Token has been specified or set. Use Set-TeamviewerAccessToken to set your AccessToken or Initialize-Teamviewer to load Teamviewer Global Variables.'
31 | }
32 | elseif ((Test-Path variable:Global:TeamviewerAccessToken ) -and !($AccessToken))
33 | {
34 | $AccessToken = $Global:TeamviewerAccessToken
35 | }
36 |
37 | Write-Verbose -Message "Updating Teamviewer Device List before Connecting to Device"
38 | Set-TeamviewerDeviceList -AccessToken $AccessToken
39 | }
40 |
41 | $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)
42 | $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
43 | }
44 |
45 | Process
46 | {
47 | [ValidateNotNullOrEmpty()]$Teamviewer = Get-ChildItem -Path "$Env:SystemDrive\Program File*\Teamviewer\Teamviewer.exe" -Recurse | Select-Object -ExpandProperty fullname
48 |
49 | Write-Verbose -Message "Teamviewer Exe Path: [$Teamviewer]"
50 |
51 | foreach ($Name in $ComputerName)
52 | {
53 | Try
54 | {
55 | $RemoteId = (Get-TeamviewerDeviceProperty -ComputerName $Name -remotecontrol_id).substring(1)
56 | Write-Verbose -Message "Connecting to ComputerName: [$Name] with Teamviewer ID: [$RemoteId]"
57 |
58 | Start-Process -FilePath $Teamviewer -ArgumentList "-i $RemoteId --Password $PlainPassword" -ErrorAction Stop -WindowStyle Maximized
59 | }
60 | catch
61 | {
62 | Throw "Failed to Connect to ComputerName: [$Name] using Teamviewer ID: [$RemoteId]"
63 | }
64 | }
65 | }
66 |
67 | End
68 | {
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Posh-Teamviewer/Public/Initialize-Teamviewer.ps1:
--------------------------------------------------------------------------------
1 | # .ExternalHelp Teamviewer-Help.xml
2 | function Initialize-Teamviewer
3 | {
4 | [CmdletBinding()]
5 | Param
6 | (
7 | [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)]
8 | [securestring]$MasterPassword
9 | )
10 |
11 | Begin
12 | {
13 | # Test if configuration file exists.
14 | $TeamviewerConfigPath = Resolve-TeamviewerConfigPath
15 |
16 | if (!(Test-Path "$($TeamviewerConfigPath)\api.key"))
17 | {
18 | throw 'Configuration has not been set, Set-TeamviewerAccessToken to configure the Access Token.'
19 | }
20 | }
21 | Process
22 | {
23 | Try
24 | {
25 | Write-Verbose -Message "Reading key from $($TeamviewerConfigPath)\api.key."
26 |
27 | $ConfigFileContent = Get-Content -Path "$($TeamviewerConfigPath)\api.key"
28 |
29 | Write-Debug -Message "Secure string is $($ConfigFileContent)"
30 |
31 | $SaltBytes = Get-Content -Encoding Byte -Path "$($TeamviewerConfigPath)\salt.rnd"
32 | $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList 'user', $MasterPassword
33 |
34 | # Derive Key, IV and Salt from Key
35 | $Rfc2898Deriver = New-Object System.Security.Cryptography.Rfc2898DeriveBytes -ArgumentList $Credentials.GetNetworkCredential().Password, $SaltBytes, 10000
36 | $KeyBytes = $Rfc2898Deriver.GetBytes(32)
37 |
38 | $SecString = ConvertTo-SecureString -Key $KeyBytes $ConfigFileContent
39 |
40 | # Decrypt the secure string.
41 | #$SecureStringToBSTR = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecString)
42 | #$AccessToken = [Runtime.InteropServices.Marshal]::PtrToStringAuto($SecureStringToBSTR)
43 |
44 | # Set session variable with the Token.
45 | #$Global:TeamviewerAccessToken = $AccessToken
46 | $Global:TeamviewerAccessToken = $SecString
47 |
48 | Write-Verbose -Message 'Token has been set.'
49 | }
50 | Catch
51 | {
52 | Throw
53 | }
54 | Try
55 | {
56 | Write-Verbose -Message "Setting Device List"
57 | Set-TeamviewerDeviceList -AccessToken $AccessToken
58 | }
59 | Catch
60 | {
61 | Throw
62 | }
63 | }
64 | End
65 | {
66 |
67 | }
68 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/Public/Set-TeamviewerAccessToken.ps1:
--------------------------------------------------------------------------------
1 | # .ExternalHelp Teamviewer-Help.xml
2 | function Set-TeamviewerAccessToken
3 | {
4 | [CmdletBinding()]
5 | Param
6 | (
7 | [Parameter(Mandatory=$true)]
8 | [securestring]$AccessToken,
9 |
10 | [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=1)]
11 | [securestring]$MasterPassword
12 | )
13 |
14 | Begin
15 | {
16 | $TeamviewerConfigPath = Resolve-TeamviewerConfigPath
17 | }
18 |
19 | Process
20 | {
21 | #$Global:TeamviewerAccessToken = $AccessToken
22 | #$SecureKeyString = ConvertTo-SecureString -String $AccessToken -AsPlainText -Force
23 | $SecureKeyString = $AccessToken
24 |
25 | # Generate a random secure Salt
26 | $SaltBytes = New-Object byte[] 32
27 | $RNG = New-Object System.Security.Cryptography.RNGCryptoServiceProvider
28 | $RNG.GetBytes($SaltBytes)
29 |
30 | $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList 'user', $MasterPassword
31 |
32 | # Derive Key, IV and Salt from Key
33 | $Rfc2898Deriver = New-Object System.Security.Cryptography.Rfc2898DeriveBytes -ArgumentList $Credentials.GetNetworkCredential().Password, $SaltBytes, 10000
34 | $KeyBytes = $Rfc2898Deriver.GetBytes(32)
35 |
36 | $EncryptedString = $SecureKeyString | ConvertFrom-SecureString -key $KeyBytes
37 |
38 | $ConfigName = 'api.key'
39 | $saltname = 'salt.rnd'
40 |
41 | if (!(Test-Path -Path "$($TeamviewerConfigPath)"))
42 | {
43 | Write-Verbose -Message 'Seems this is the first time the config has been set.'
44 | Write-Verbose -Message "Creating folder $($TeamviewerConfigPath)"
45 |
46 | New-Item -ItemType directory -Path "$($TeamviewerConfigPath)" | Out-Null
47 | }
48 |
49 | Write-Verbose -Message "Saving the information to configuration file $("$($TeamviewerConfigPath)\$ConfigName")"
50 |
51 | "$($EncryptedString)" | Set-Content "$($TeamviewerConfigPath)\$ConfigName" -Force
52 |
53 | # Saving salt in to the file.
54 | Set-Content -Value $SaltBytes -Encoding Byte -Path "$($TeamviewerConfigPath)\$saltname" -Force
55 | }
56 | End
57 | {
58 |
59 | }
60 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/Public/Set-TeamviewerDeviceList.ps1:
--------------------------------------------------------------------------------
1 | # .ExternalHelp Teamviewer-Help.xml
2 | Function Set-TeamviewerDeviceList
3 | {
4 | [CmdletBinding()]
5 | param
6 | (
7 | [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$false)]
8 | [securestring]$AccessToken
9 | )
10 |
11 | Begin
12 | {
13 | Write-Verbose -Message 'Starting: Set Teamviewer Device List'
14 |
15 | if (!(Test-Path variable:Global:TeamviewerAccessToken ) -and !($AccessToken))
16 | {
17 | throw 'No Teamviewer Access Token has been specified or set. Use Set-TeamviewerAccessToken to set your AccessToken or Initialize-Teamviewer to load Teamviewer Global Variables.'
18 | }
19 | elseif ((Test-Path variable:Global:TeamviewerAccessToken ) -and !($AccessToken))
20 | {
21 | $AccessToken = $Global:TeamviewerAccessToken
22 | }
23 |
24 | $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($AccessToken)
25 | $PlainAccessToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
26 | }
27 |
28 | Process
29 | {
30 | $Headers = @{ 'Authorization' = "Bearer $PlainAccessToken" }
31 | $ContetType = 'application/json; charset=utf-8'
32 | $Uri = 'https://webapi.teamviewer.com/api/v1/devices/'
33 |
34 | Write-Verbose -Message "[GET] RestMethod: [$Uri]"
35 |
36 | $Result = Invoke-RestMethod -Method Get -Uri $Uri -Headers $Headers -ContentType $ContetType -ErrorVariable TVError -ErrorAction SilentlyContinue
37 |
38 | if ($TVError)
39 | {
40 | $JsonError = $TVError.Message | ConvertFrom-Json
41 | $HttpResponse = $TVError.ErrorRecord.Exception.Response
42 | Throw "Error: $($JsonError.error) `nDescription: $($JsonError.error_description) `nErrorCode: $($JsonError.error_code) `nHttp Status Code: $($HttpResponse.StatusCode.value__) `nHttp Description: $($HttpResponse.StatusDescription)"
43 | }
44 | else
45 | {
46 | Write-Verbose -Message "Setting Device List to variable for use by other commands."
47 |
48 | $Global:TeamviewerDeviceList = $Result
49 | }
50 | }
51 |
52 | End
53 | {
54 |
55 | }
56 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/Public/Update-TeamviewerDevice.ps1:
--------------------------------------------------------------------------------
1 | # .ExternalHelp Teamviewer-Help.xml
2 | Function Update-TeamviewerDevice
3 | {
4 | [CmdletBinding()]
5 | param
6 | (
7 | [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
8 | [string]$ComputerName,
9 |
10 | [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
11 | [string]$Description,
12 |
13 | [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
14 | [string]$Alias,
15 |
16 | [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
17 | [string]$Password,
18 |
19 | [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
20 | [Switch]$UpdateDeviceList,
21 |
22 | [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$false)]
23 | [securestring]$AccessToken
24 | )
25 |
26 | Begin
27 | {
28 | Write-Verbose -Message 'Starting: Update Teamviewer Device'
29 |
30 | if (!(Test-Path variable:Global:TeamviewerAccessToken ) -and !($AccessToken))
31 | {
32 | throw 'No Teamviewer Access Token has been specified or set. Use Set-TeamviewerAccessToken to set your AccessToken or Initialize-Teamviewer to load Teamviewer Global Variables.'
33 | }
34 | elseif ((Test-Path variable:Global:TeamviewerAccessToken ) -and !($AccessToken))
35 | {
36 | $AccessToken = $Global:TeamviewerAccessToken
37 | }
38 |
39 | $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($AccessToken)
40 | $PlainAccessToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
41 |
42 | if ($PSBoundParameters.ContainsKey('UpdateDeviceList'))
43 | {
44 | Write-Verbose -Message "Updating Teamviewer Device List before Updating Device"
45 | Set-TeamviewerDeviceList -AccessToken $AccessToken
46 | }
47 | }
48 |
49 | Process
50 | {
51 | Write-Verbose "Changing Device Information: [$ComputerName]"
52 |
53 | Try
54 | {
55 | Write-Verbose -Message "Getting the Device ID for [$ComputerName]"
56 | $deviceId = Get-TeamviewerDeviceProperty -ComputerName $ComputerName -device_id
57 | }
58 | catch
59 | {
60 | Throw $Error[0]
61 | }
62 |
63 | $Headers = @{ 'Authorization' = "Bearer $PlainAccessToken" }
64 | $ContetType = 'application/json; charset=utf-8'
65 | $Uri = 'https://webapi.teamviewer.com/api/v1/devices/' + $deviceId
66 |
67 | Write-Verbose -Message "[PUT] RestMethod: [$Uri]"
68 |
69 | $deviceFields = @{}
70 |
71 | if ($PSBoundParameters.ContainsKey('Description'))
72 | {
73 | Write-Verbose -Message "Adding Description Field: [$Description]"
74 | $deviceFields.description = $Description
75 | }
76 |
77 | if ($PSBoundParameters.ContainsKey('Password'))
78 | {
79 | Write-Verbose -Message "Adding Password Field"
80 | $deviceFields.password = $Password
81 | }
82 |
83 | if ($PSBoundParameters.ContainsKey('Alias'))
84 | {
85 | Write-Verbose -Message "Adding Alias Field: [$Alias]"
86 | $deviceFields.alias = $Alias
87 | }
88 |
89 | $psobject = New-Object psobject -Property $deviceFields
90 | $Body = $psobject | Microsoft.PowerShell.Utility\ConvertTo-Json
91 |
92 | Write-Verbose -Message "Body: $($Body)"
93 |
94 | Invoke-RestMethod -Method Put -Uri $Uri -Headers $Headers -ContentType $ContetType -Body $Body -ErrorVariable TVError -ErrorAction SilentlyContinue
95 |
96 | if ($TVError)
97 | {
98 | $JsonError = $TVError.Message | ConvertFrom-Json
99 | $HttpResponse = $TVError.ErrorRecord.Exception.Response
100 | Throw "Error: $($JsonError.error) `nDescription: $($JsonError.error_description) `nErrorCode: $($JsonError.error_code) `nHttp Status Code: $($HttpResponse.StatusCode.value__) `nHttp Description: $($HttpResponse.StatusDescription)"
101 | }
102 | }
103 |
104 | End
105 | {
106 |
107 | }
108 | }
--------------------------------------------------------------------------------
/Posh-Teamviewer/en-US/Posh-Teamviewer-help.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Connect-Teamviewer
6 | Connect
7 | Teamviewer
8 | Connects to a Teamviewer Device
9 |
10 |
11 |
12 | Connects to a Teamviewer Device using ComputerName.
13 |
14 | Requires a Teamviewer Access Token to be set via Set-TeamviewerAccessToken. If in a new PowerShell Session, you can load a saved Access Token with Initialize-Teamviewer.
15 |
16 |
17 | Connect-Teamviewer
18 | AccessToken
19 | The Teamviewer Access Token.
20 |
21 |
22 | SecureString
23 | SecureString
24 |
25 |
26 |
27 | ComputerName
28 | The name or the alias of the Device to be connected to.
29 |
30 |
31 | String[]
32 | String[]
33 |
34 |
35 |
36 | Password
37 | The Teamviewer Device password.
38 |
39 |
40 | SecureString
41 | SecureString
42 |
43 |
44 |
45 | UpdateDeviceList
46 | Update the Devices List Global Variable that the Device information is stored. Teamviewer accounts with a large device list can take a very long time to send a response back with Device Ids. To get around this Device information is gathered and stored when Initialize-Teamviewer is ran to decrypt the Teamviewer Access Token. This allows quick Device information look up.
47 |
48 |
49 | SwitchParameter
50 |
51 | False
52 |
53 |
54 |
55 | AccessToken
56 | The Teamviewer Access Token.
57 |
58 |
59 | SecureString
60 | SecureString
61 |
62 |
63 |
64 | ComputerName
65 | The name or the alias of the Device to be connected to.
66 |
67 |
68 | String[]
69 | String[]
70 |
71 |
72 |
73 | Password
74 | The Teamviewer Device password.
75 |
76 |
77 | SecureString
78 | SecureString
79 |
80 |
81 |
82 | UpdateDeviceList
83 | Update the Devices List Global Variable that the Device information is stored. Teamviewer accounts with a large device list can take a very long time to send a response back with Device Ids. To get around this Device information is gathered and stored when Initialize-Teamviewer is ran to decrypt the Teamviewer Access Token. This allows quick Device information look up.
84 |
85 |
86 | SwitchParameter
87 | SwitchParameter
88 |
89 | False
90 |
91 |
92 | System.String[]
93 |
94 |
95 |
96 |
97 |
98 |
99 | System.Object
100 |
101 |
102 |
103 |
104 |
105 |
106 | Before you can use this Command you need to set you Teamviewer AccessToken with Set-TeamviewerAccessToken or load a previously saved AccessToken with Initialize-Teamviewer.
107 |
108 |
109 |
110 | -------------------------- EXAMPLE 1 --------------------------
111 | PS C:\> Connect-Teamviewer -ComputerName 'TestName' -Password $SecureString
112 | Connects to Teamviewer device using supplied password as Secure String.
113 |
114 |
115 |
116 | -------------------------- EXAMPLE 2 --------------------------
117 | PS C:\> Connect-Teamviewer -ComputerName 'TestName'
118 | Connects to Teamviewer device and prompts the User to enter the Device Password.
119 |
120 |
121 |
122 | -------------------------- EXAMPLE 3 --------------------------
123 | PS C:\> $ComputerList = @('Test1','Test2')
124 | PS C:\> Connect-Teamviewer -ComputerName $ComputerList
125 | Connects to Teamviewer devices Test1 and Test2 and prompts the User to enter the Device Password.
126 |
127 |
128 |
129 | -------------------------- EXAMPLE 4 --------------------------
130 | PS C:\> Connect-Teamviewer -ComputerName 'Test'
131 | The user is prompted to select a Device from a list of Matches of Devices with the word 'Test' in the name.
132 |
133 |
134 |
135 | -------------------------- EXAMPLE 5 --------------------------
136 | PS C:\> Connect-Teamviewer -ComputerName 'TestName' -UpdateDeviceList
137 | Updates the stored Device list before connecting to the Device. Requires the Teamviewer AccessToken to be set using Set-TeamviewerAccessToken or Initialize-Teamviewer to load a previously saved one.
138 |
139 |
140 |
141 |
142 | Online Version
143 | http://posh-teamviewer.readthedocs.io/en/latest/Commands/Connect-Teamviewer/
144 |
145 | Markdown Version
146 | https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Connect-Teamviewer.md
147 |
148 | Documentation
149 | https://readthedocs.org/projects/posh-teamviewer/
150 |
151 | PSGallery
152 | https://www.powershellgallery.com/packages/posh-teamviewer/
153 |
154 | Create Teamviewer Access Token
155 | https://integrate.teamviewer.com/en/develop/api/get-started/#createScript
156 |
157 | Teamviewer Api Documentation
158 | https://integrate.teamviewer.com/en/develop/api/
159 |
160 |
161 |
162 |
163 | Initialize-Teamviewer
164 | Initialize
165 | Teamviewer
166 | Reads the Teamviewer AccessToken stored in the Users Appdata Folder and creates a DeviceList.
167 |
168 |
169 |
170 | Reads the Teamviewer AccessToken stored in the Users $env:Appdata\Teamviewer Folder and sets a Global variable with it's SecureString value. Queries the Teamviewer Api to create a Device List and stores it as a Global variable.
171 |
172 |
173 | Initialize-Teamviewer
174 | MasterPassword
175 | The Master Password the AccessToken was Encrypted with using Set-TeamviewerAccessToken.
176 |
177 |
178 | SecureString
179 | SecureString
180 |
181 |
182 |
183 |
184 |
185 | MasterPassword
186 | The Master Password the AccessToken was Encrypted with using Set-TeamviewerAccessToken.
187 |
188 |
189 | SecureString
190 | SecureString
191 |
192 |
193 |
194 |
195 | System.Security.SecureString
196 |
197 |
198 |
199 |
200 |
201 |
202 | System.Object
203 |
204 |
205 |
206 |
207 |
208 |
209 | Special thanks to Carlos Perez for the AccessToken Encryption Code.
210 |
211 |
212 |
213 | -------------------------- EXAMPLE 1 --------------------------
214 | PS C:\> Initialize-Teamviewer -MasterPassword $SecureString
215 | Reads the Teamviewer AccessToken and sets the $Global:TeamviewerAccessToken variable with it's SecureString Value. Builds a Device List and sets it as $Global:TeamviewerDeviceList Variable
216 |
217 |
218 |
219 | -------------------------- EXAMPLE 2 --------------------------
220 | PS C:\> Initialize-Teamviewer
221 | Prompts the user for their MasterPassword and then reads the Teamviewer AccessToken and sets the `$Global:TeamviewerAccessToken variable. Builds a Device List and sets it as $Global:TeamviewerDeviceList Variable
222 |
223 |
224 |
225 |
226 | Online Version
227 | http://posh-teamviewer.readthedocs.io/en/latest/Commands/Initialize-Teamviewer/
228 |
229 | Markdown Version
230 | https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Initialize-Teamviewer.md
231 |
232 | Documentation
233 | https://readthedocs.org/projects/posh-teamviewer/
234 |
235 | PSGallery
236 | https://www.powershellgallery.com/packages/posh-teamviewer/
237 |
238 | Carlos Perez Github
239 | https://github.com/darkoperator
240 |
241 | Create Teamviewer Access Token
242 | https://integrate.teamviewer.com/en/develop/api/get-started/#createScript
243 |
244 | Teamviewer Api Documentation:
245 | https://integrate.teamviewer.com/en/develop/api/
246 |
247 |
248 |
249 |
250 | Set-TeamviewerAccessToken
251 | Set
252 | TeamviewerAccessToken
253 | Encrypts the User's Teamviewer AccessToken and sets the SecureString value as a Global Variable.
254 |
255 |
256 |
257 | Encrypts the User's Teamviewer AccessToken with a Master Password and sets the SecureString value as $Global:TeamviewerAccessToken Variable.
258 |
259 |
260 | Set-TeamviewerAccessToken
261 | MasterPassword
262 | The Master Password the AccessToken will be Encrypted with.
263 |
264 |
265 | SecureString
266 | SecureString
267 |
268 |
269 |
270 | AccessToken
271 | The Teamviewer Access Token.
272 |
273 |
274 | SecureString
275 | SecureString
276 |
277 |
278 |
279 |
280 |
281 | AccessToken
282 | The Teamviewer Access Token.
283 |
284 |
285 | SecureString
286 | SecureString
287 |
288 |
289 |
290 | MasterPassword
291 | The Master Password the AccessToken will be Encrypted with.
292 |
293 |
294 | SecureString
295 | SecureString
296 |
297 |
298 |
299 |
300 | System.Security.SecureString
301 |
302 |
303 |
304 |
305 |
306 |
307 | System.Object
308 |
309 |
310 |
311 |
312 |
313 |
314 | Special thanks to Carlos Perez for the AccessToken Encryption Code.
315 |
316 |
317 |
318 | -------------------------- EXAMPLE 1 --------------------------
319 | PS C:\> Set-TeamviewerAccessToken -AccessToken $SecureAccessTokenString -MasterPassword $SecureString
320 | Sets the AccessToken using the supplied Secure String Password.
321 |
322 |
323 |
324 | -------------------------- EXAMPLE 2 --------------------------
325 | PS C:\> Set-TeamviewerAccessToken
326 | Prompts the User for their Master Password and AccessToken.
327 |
328 |
329 |
330 |
331 | Online Version
332 | http://posh-teamviewer.readthedocs.io/en/latest/Commands/Set-TeamviewerAccessToken/
333 |
334 | Markdown Version
335 | https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Set-TeamviewerAccessToken.md
336 |
337 | Documentation
338 | https://readthedocs.org/projects/posh-teamviewer/
339 |
340 | PSGallery
341 | https://www.powershellgallery.com/packages/posh-teamviewer/
342 |
343 | Carlos Perez Github
344 | https://github.com/darkoperator
345 |
346 | Create Teamviewer Access Token
347 | https://integrate.teamviewer.com/en/develop/api/get-started/#createScript
348 |
349 | Teamviewer Api Documentation
350 | https://integrate.teamviewer.com/en/develop/api/
351 |
352 |
353 |
354 |
355 | Set-TeamviewerDeviceList
356 | Set
357 | TeamviewerDeviceList
358 | Creates a Device List Global Variable with Teamviewer Device Information.
359 |
360 |
361 |
362 | Creates a Global Variable $Global:TeamviewerDeviceList with a Device List with Teamviewer Device Information that other commands can use without relying on the Teamviewer Api. The Teamviewer Api can be slow if querying a large number of devices.
363 |
364 |
365 | Set-TeamviewerDeviceList
366 | AccessToken
367 | The Teamviewer Access Token.
368 |
369 |
370 | SecureString
371 | SecureString
372 |
373 |
374 |
375 |
376 |
377 | AccessToken
378 | The Teamviewer Access Token.
379 |
380 |
381 | SecureString
382 | SecureString
383 |
384 |
385 |
386 |
387 | None
388 |
389 |
390 |
391 |
392 |
393 |
394 | System.Object
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 | -------------------------- EXAMPLE 1 --------------------------
406 | PS C:\> Set-TeamviewerDeviceList
407 | Sets the Device List Global Variable.
408 |
409 |
410 |
411 |
412 | Online Version
413 | http://posh-teamviewer.readthedocs.io/en/latest/Commands/Set-TeamviewerDeviceList/
414 |
415 | Markdown Version
416 | https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Set-TeamviewerDeviceList.md
417 |
418 | Documentation
419 | https://readthedocs.org/projects/posh-teamviewer/
420 |
421 | PSGallery
422 | https://www.powershellgallery.com/packages/posh-teamviewer/
423 |
424 | Create Teamviewer Access Token
425 | https://integrate.teamviewer.com/en/develop/api/get-started/#createScript
426 |
427 | Teamviewer Api Documentation:
428 | https://integrate.teamviewer.com/en/develop/api/
429 |
430 |
431 |
432 |
433 | Update-TeamviewerDevice
434 | Update
435 | TeamviewerDevice
436 | Updates Properties of a Teamviewer Device.
437 |
438 |
439 |
440 | Updates Properties of a Teamviewer Device. Those properties are Alias(Device's Name), Description, and Password.
441 |
442 |
443 | Update-TeamviewerDevice
444 | ComputerName
445 | The Name of the Device.
446 |
447 |
448 | String
449 | String
450 |
451 |
452 |
453 | Description
454 | The Description of the Device.
455 |
456 |
457 | String
458 | String
459 |
460 |
461 |
462 | Alias
463 | The new Name of the Device.
464 |
465 |
466 | String
467 | String
468 |
469 |
470 |
471 | Password
472 | The new Password for the Device. This is not the Password set by the Client, but the one saved in Teamviewer for connecting without a Password.
473 |
474 |
475 | String
476 | String
477 |
478 |
479 |
480 | AccessToken
481 | The Teamviewer AccessToken
482 |
483 |
484 | SecureString
485 | SecureString
486 |
487 |
488 |
489 | UpdateDeviceList
490 | Update the Devices List Global Variable that the Device information is stored. Teamviewer accounts with a large device list can take a very long time to send a response back with Device Ids. To get around this Device information is gathered and stored when Initialize-Teamviewer is ran to decrypt the Teamviewer Access Token. This allows quick Device information look up.
491 |
492 |
493 | SwitchParameter
494 |
495 | False
496 |
497 |
498 |
499 | AccessToken
500 | The Teamviewer AccessToken
501 |
502 |
503 | SecureString
504 | SecureString
505 |
506 |
507 |
508 | Alias
509 | The new Name of the Device.
510 |
511 |
512 | String
513 | String
514 |
515 |
516 |
517 | ComputerName
518 | The Name of the Device.
519 |
520 |
521 | String
522 | String
523 |
524 |
525 |
526 | Description
527 | The Description of the Device.
528 |
529 |
530 | String
531 | String
532 |
533 |
534 |
535 | Password
536 | The new Password for the Device. This is not the Password set by the Client, but the one saved in Teamviewer for connecting without a Password.
537 |
538 |
539 | String
540 | String
541 |
542 |
543 |
544 | UpdateDeviceList
545 | Update the Devices List Global Variable that the Device information is stored. Teamviewer accounts with a large device list can take a very long time to send a response back with Device Ids. To get around this Device information is gathered and stored when Initialize-Teamviewer is ran to decrypt the Teamviewer Access Token. This allows quick Device information look up.
546 |
547 |
548 | SwitchParameter
549 | SwitchParameter
550 |
551 | False
552 |
553 |
554 | System.String
555 |
556 | System.Management.Automation.SwitchParameter
557 |
558 |
559 |
560 |
561 | System.Object
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 | -------------------------- EXAMPLE 1 --------------------------
573 | PS C:\> Update-TeamviewerDevice -ComputerName 'Test1' -Description 'Test Lab Device 1' -Alias 'Test1 (Test Lab)'
574 | This command updates the Teamviewer Description and Alias of the Device named 'Test1'.
575 |
576 |
577 |
578 | -------------------------- EXAMPLE 2 --------------------------
579 | PS C:\> Update-TeamviewerDevice -ComputerName 'Test1' -Password $NewPassword
580 | This command updates the Teamviewer Password of the Device named 'Test1'.
581 |
582 |
583 |
584 |
585 | Online Version
586 | http://posh-teamviewer.readthedocs.io/en/latest/Commands/Set-TeamviewerDeviceList/
587 |
588 | Markdown Version
589 | https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Set-TeamviewerDeviceList.md
590 |
591 | Documentation
592 | https://readthedocs.org/projects/posh-teamviewer/
593 |
594 | PSGallery
595 | https://www.powershellgallery.com/packages/posh-teamviewer/
596 |
597 | Create Teamviewer Access Token
598 | https://integrate.teamviewer.com/en/develop/api/get-started/#createScript
599 |
600 | Teamviewer Api Documentation:
601 | https://integrate.teamviewer.com/en/develop/api/
602 |
603 |
604 |
605 |
606 |
607 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://ci.appveyor.com/project/gerane/posh-teamviewer/branch/master)
2 | [](http://posh-teamviewer.readthedocs.io/en/latest/?badge=latest)
3 |
4 | # Posh-Teamviewer Module
5 |
6 | The Teamviewer PowerShell Module allows users to connect and edit device properties using the Teamviewer API. Online Documentation can be found on [ReadTheDocs](https://readthedocs.org/projects/posh-teamviewer/)
7 |
8 | ## Installation
9 |
10 | Install from PSGallery.
11 |
12 | ```powershell
13 | PS> Install-Module -Name Posh-Teamviewer
14 | ```
15 |
16 | ## Set Access Token
17 |
18 | To get started create a Teamviewer script Access Token. For detailed insctructions follow this guide: [Create Script](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript). You can also find the full API Documentation here: [API Documentation](https://integrate.teamviewer.com/en/develop/api/documentation/). Once you have your Access Token, use the command `Set-TeamviewerAccessToken` to store the Access Token and set the variable `$Global:TeamviewerAccessToken`. This command encrypts the AccessToken in a file located at `$env:APPDATA\Teamviewer` using PBKDF2 to derive a key with a Master Password and salt. Special thanks to [Carlos Perez](https://github.com/darkoperator) for the Code and Help associated with this. Here is an example of Setting the Access Token.
19 |
20 | ```powershell
21 | PS> Set-TeamviewerAccessToken -AccessToken '1234-SWDwf23vawef4122345asfg'
22 | ```
23 |
24 | 
25 |
26 | ## Load Saved Access Token
27 |
28 | To Load an encrypted Access Token into the Current Session, run the following Command:
29 |
30 | ```powershell
31 | PS> Initialize-Teamviewer -MasterPassword (Read-Host -AsSecureString)
32 | ```
33 |
34 | This command will set the following variables:
35 |
36 | * **$Global:TeamviewerAccessToken** - The Teamviewer Access Token.
37 | * **$Global:TeamviewerConfigPath** - The Path to the Teamviewer Appdata Folder.
38 | * **$Global:TeamviewerDeviceList** - A stored list of Device Details from the Teamviewer API.
39 |
40 | > **NOTE:** Teamviewer requires a Device ID to query that devices information. When **Initialize-Teamviewer** is used at the start of a session, it runs **Set-TeamviewerDeviceList** in the background to build an initial list of Device Details. This is to help in situations where an account has a very large number of devices attached to it. Responses could take upwards of 30 or more seconds when gathering information on thousdands of devices. **Initialize-Teamviewer** may run slightly longer than expected due to this, but keeps the time of the other commands to a minimum.
41 |
42 | ## Updating the Device List
43 |
44 | The first way To update the Device List is to use **Update-DeviceList**. If you need the Device Information to be up to date before running a specific command that relies on this list, a switch parameter `-UpdateDeviceList` is available that will update the List at the beginning of the command.
45 |
46 | ## Commands and Command Help
47 |
48 | | Command | Help |
49 | |-------------------------------|---------------------------------------------------------------------------------|
50 | | **Connect-Teamviewer** | [Connect-Teamviewer.md](docs/Commands/Connect-Teamviewer.md) |
51 | | **Initialize-Teamviewer** | [Initialize-Teamviewer.md](docs/Commands/Initialize-Teamviewer.md) |
52 | | **Set-TeamviewerAccessToken** | [Set-TeamviewerAccessToken.md](docs/Commands/Set-TeamviewerAccessToken.md) |
53 | | **Set-TeamviewerDeviceList** | [Set-TeamviewerDeviceList.md](docs/Commands/Set-TeamviewerDeviceList.md) |
54 | | **Update-TeamviewerDevice** | [Update-TeamviewerDevice.md](docs/Commands/Update-TeamviewerDevice.md) |
55 |
56 |
57 | ## Links
58 |
59 | - PSGallery - [Posh-Teamviewer](https://www.powershellgallery.com/packages/posh-teamviewer/)
60 | - Github - [Brandon Padgett](https://github.com/gerane)
61 | - Twitter - [@brandonpadgett](https://twitter.com/BrandonPadgett)
62 | - Website - [BrandonPadgett.com](http://brandonpadgett.com)
63 | - Documentation - [ReadTheDocs](https://readthedocs.org/projects/posh-teamviewer/)
64 |
65 |
66 | ## License
67 |
68 | [MIT](LICENSE)
69 |
70 |
71 | ## Notes
72 |
73 | * [Carlos Perez](https://twitter.com/Carlos_Perez) for the ApiKey Encryption work.
74 | * [Stefan Stranger](https://twitter.com/sstranger) for giving me some ideas, whether he realized it or not.
75 | * [Warren Frame](https://twitter.com/psCookieMonster) for his awesome [PSDeploy](https://github.com/RamblingCookieMonster/PSDeploy) Module.
76 | * [June Blender](https://twitter.com/juneb_get_help) for her [Module Help Pester Tests](https://github.com/juneb/PowerShellHelpDeepDive).
77 |
--------------------------------------------------------------------------------
/Tests/Connect-Teamviewer.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 |
5 | InModuleScope 'Posh-Teamviewer' {
6 |
7 | Describe 'Connect-Teamviewer' {
8 | $AccessToken = ConvertTo-SecureString -String 'Fake-AccessTokenText123456789' -AsPlainText -Force
9 | $Password = ConvertTo-SecureString -String 'FakePassword' -AsPlainText -Force
10 |
11 | Context 'No Teamviewer Exe Found' {
12 | $MockedRemoteId = 'r123456789'
13 | Mock Get-ChildItem { Return [PSCustomObject]@{FullName="C:\Fake\Path.exe"} } -Verifiable
14 | Mock Select-Object {}
15 | Mock Get-TeamviewerDeviceProperty {}
16 | Mock Start-Process {}
17 |
18 | It 'Should Fail Variable Validation' {
19 | $Results = { Connect-Teamviewer -ComputerName 'Test1' -Password $Password -AccessToken $AccessToken }
20 | $Results | Should Throw
21 | }
22 | }
23 |
24 | Context 'Connects to Device without Update Switch' {
25 | $MockedRemoteId = 'r123456789'
26 | Mock Get-ChildItem { Return [PSCustomObject]@{FullName="C:\Fake\Path.exe"} } -Verifiable
27 | Mock Get-TeamviewerDeviceProperty { Return $MockedRemoteId } -Verifiable
28 | Mock Start-Process { Return $RemoteId } -Verifiable
29 | Mock Set-TeamviewerDeviceList {}
30 |
31 | It 'Return Proper Remote ID' {
32 | $Results = Connect-Teamviewer -ComputerName 'TestName' -Password $Password -AccessToken $AccessToken
33 | $Results | Should Be $MockedRemoteId.substring(1)
34 | }
35 |
36 | It "Should Assert Mocks" {
37 | Assert-VerifiableMocks
38 | }
39 |
40 | It 'Should Not Set Device List' {
41 | Assert-MockCalled Set-TeamviewerDeviceList -Times 0
42 | }
43 | }
44 |
45 | Context 'Connects to Device with Update Switch' {
46 | $MockedRemoteId = 'r123456789'
47 | Mock Get-ChildItem { Return [PSCustomObject]@{FullName="C:\Fake\Path.exe"} } -Verifiable
48 | Mock Get-TeamviewerDeviceProperty { Return $MockedRemoteId } -Verifiable
49 | Mock Start-Process { Return $RemoteId } -Verifiable
50 | Mock Set-TeamviewerDeviceList {} -Verifiable
51 |
52 | It 'Return Proper Remote ID' {
53 | $Results = Connect-Teamviewer -ComputerName 'Test1' -Password $Password -AccessToken $AccessToken -UpdateDeviceList
54 | $Results | Should Be $MockedRemoteId.substring(1)
55 | }
56 |
57 | It "Should Assert Mocks" {
58 | Assert-VerifiableMocks
59 | }
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/Tests/Files/api.key:
--------------------------------------------------------------------------------
1 | 76492d1116743f0423413b16050a5345MgB8AGQAOAAwAFcAZABDAEYAVwAzAHcASQBOAEYAMwAyAGUAQgB2ADUAVABRAGcAPQA9AHwAOABkAGMANgA5ADUANABlADEAZABkADMAOAAxADAAOABmADkANwA3ADIAYwBiADEAOABhADMANgBlAGYAOAAyAGEANAA4ADYAOQBiADcAMQAwADAAOQA1AGQAZQA3ADYAYgA1AGYAMQBiADgAZQA5ADYAMQAwADQANgBhAGEANQA1ADIAYwAwADMAZABhADIAMABjAGUAYQBiADEAZgAyADYAYQBhAGUANwBkADUANAA4ADEAYgAwADMAMAAxADIANQBmAGIAZAA2AGMANwA5ADMAYQBmADYAOAAwAGYANwBkADgANQA2ADAAZABmAGMANgA2ADIANABjAGIAZgA4AA==
2 |
--------------------------------------------------------------------------------
/Tests/Files/salt.rnd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gerane/Posh-Teamviewer/17629621e107dc41fe4dd9d432dc7712779f467b/Tests/Files/salt.rnd
--------------------------------------------------------------------------------
/Tests/Get-TeamviewerDeviceProperty.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 | $Json = @"
5 | {
6 | "devices":[
7 | {
8 | "remotecontrol_id":"r123456789",
9 | "device_id":"d12345678",
10 | "alias":"Device1",
11 | "groupid":"g1234567",
12 | "online_state":"Online",
13 | "supported_features":"remote_control, chat",
14 | "description":"Test Device 1"
15 | },
16 | {
17 | "remotecontrol_id":"r987654321",
18 | "device_id":"d87654321",
19 | "alias":"Device2",
20 | "groupid":"g7654321",
21 | "online_state":"Offline",
22 | "supported_features":"chat",
23 | "description":"Test Device 2"
24 | },
25 | {
26 | "remotecontrol_id":"r987612345",
27 | "device_id":"d87612345",
28 | "alias":"Device3",
29 | "groupid":"g7612345",
30 | "online_state":"Online",
31 | "supported_features":"remote_control",
32 | "description":"Test Device 3"
33 | }
34 | ]
35 | }
36 | "@
37 |
38 | $Global:TeamviewerDeviceList = $Json | ConvertFrom-Json
39 |
40 | InModuleScope 'Posh-Teamviewer' {
41 |
42 | Describe 'Get-TeamviewerDeviceProperty' {
43 |
44 | Context 'Device_id' {
45 | Mock Get-TeamviewerChoice { Return 0 }
46 |
47 | It 'Throw because Device not found' {
48 | $Results = { Get-TeamviewerDeviceProperty -ComputerName 'Device4' -device_id }
49 | $Results | Should Throw
50 | }
51 |
52 | It 'Should Return Device1 Device_id' {
53 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device1' -device_id
54 | $Results | Should Be 'd12345678'
55 | }
56 |
57 | It 'Should Return Device2 Device_id' {
58 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device2' -device_id
59 | $Results | Should Be 'd87654321'
60 | }
61 |
62 | It 'Should Return Device3 Device_id' {
63 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device3' -device_id
64 | $Results | Should Be 'd87612345'
65 | }
66 |
67 | It 'Should Return Device1 Device_id from Choice' {
68 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device' -device_id
69 | $Results | Should Be 'd12345678'
70 | }
71 | }
72 |
73 | Context 'remotecontrol_id' {
74 | Mock Get-TeamviewerChoice { Return 1 }
75 |
76 | It 'Throw because Device not found' {
77 | $Results = { Get-TeamviewerDeviceProperty -ComputerName 'Device4' -remotecontrol_id }
78 | $Results | Should Throw
79 | }
80 |
81 | It 'Should Return Device1 remotecontrol_id' {
82 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device1' -remotecontrol_id
83 | $Results | Should Be 'r123456789'
84 | }
85 |
86 | It 'Should Return Device2 remotecontrol_id' {
87 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device2' -remotecontrol_id
88 | $Results | Should Be 'r987654321'
89 | }
90 |
91 | It 'Should Return Device3 remotecontrol_id' {
92 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device3' -remotecontrol_id
93 | $Results | Should Be 'r987612345'
94 | }
95 |
96 | It 'Should Return Device1 remotecontrol_id from Choice' {
97 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device' -remotecontrol_id
98 | $Results | Should Be 'r987654321'
99 | }
100 | }
101 |
102 | Context 'description' {
103 | Mock Get-TeamviewerChoice { Return 2 }
104 |
105 | It 'Throw because Device not found' {
106 | $Results = { Get-TeamviewerDeviceProperty -ComputerName 'Device4' -description }
107 | $Results | Should Throw
108 | }
109 |
110 | It 'Should Return Device1 description' {
111 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device1' -description
112 | $Results | Should Be 'Test Device 1'
113 | }
114 |
115 | It 'Should Return Device2 description' {
116 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device2' -description
117 | $Results | Should Be 'Test Device 2'
118 | }
119 |
120 | It 'Should Return Device3 description' {
121 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device3' -description
122 | $Results | Should Be 'Test Device 3'
123 | }
124 |
125 | It 'Should Return Device1 description from Choice' {
126 | $Results = Get-TeamviewerDeviceProperty -ComputerName 'Device' -description
127 | $Results | Should Be 'Test Device 3'
128 | }
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/Tests/Initialize-Teamviewer.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 | $Global:TeamviewerAccessToken = $null
5 |
6 | InModuleScope 'Posh-Teamviewer' {
7 |
8 | Describe 'Initialize-Teamviewer' {
9 | $MasterPassword = ConvertTo-SecureString -String 'FakePassword' -AsPlainText -Force
10 |
11 | Context 'Sets Global AccessToken Variable' {
12 | Mock Resolve-TeamviewerConfigPath { Return (Resolve-Path "$Script:ModuleRoot\..\Tests\Files") }
13 | Mock Test-Path { Return $true }
14 | Mock Set-TeamviewerDeviceList {}
15 |
16 | It 'Global Access Token Should not match' {
17 | $Results = $Global:TeamviewerAccessToken
18 | $Results | Should Be $Null
19 | }
20 |
21 | Initialize-Teamviewer -MasterPassword $MasterPassword
22 |
23 | It 'Sets Global Access Token Variable' {
24 | $Results = Test-Path variable:Global:TeamviewerDeviceList
25 | $Results | Should Be $true
26 | }
27 |
28 | It 'Decrypts Apikey' {
29 | $Results = { Initialize-Teamviewer -MasterPassword $MasterPassword }
30 | $Results | Should Not Throw
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Tests/Module.Help.Tests.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Tests the PowerShell help for the commands in a module.
4 |
5 | .DESCRIPTION
6 | This Pester test verifies that the commands in a module have basic help content.
7 | It works on all command types and both comment-based and XML help.
8 |
9 | This test verifies that Get-Help is not autogenerating help because it cannot
10 | find any help for the command. Then, it checks for the following help elements:
11 | - Synopsis
12 | - Description
13 | - Parameter:
14 | - A description of each parameter.
15 | - An accurate value for the Mandatory property.
16 | - An accurate value for the .NET type of the parameter value.
17 | - No extra parameters:
18 | - Verifies that there are no parameters in help that are not also in the code.
19 |
20 | When testing attributes of parameters that appear in multiple parameter sets,
21 | this test uses the parameter that appears in the default parameter set, if one
22 | is defined.
23 |
24 | You can run this Tests file from any location. For a help test that is located in a module
25 | directory, use https://github.com/juneb/PesterTDD/InModule.Help.Tests.ps1
26 |
27 | .PARAMETER ModuleName
28 | Enter the name of the module to test. You can enter only one name at a time. This
29 | parameter is mandatory.
30 |
31 | .PARAMETER RequiredVersion
32 | Enter the version of the module to test. This parameter is optional. If you
33 | omit it, the test runs on the latest version of the module in $env:PSModulePath.
34 |
35 | .EXAMPLE
36 | .\Module.Help.Tests.ps1 -ModuleName Pester -RequiredVersion 3.4.0
37 | This command runs the tests on the commands in Pester 3.4.0.
38 |
39 | .EXAMPLE
40 | .\Module.Help.Tests.ps1 -ModuleName Pester
41 | This command runs the tests on the commands in latest local version of the
42 | Pester module.
43 |
44 |
45 | .NOTES
46 | ===========================================================================
47 | Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119
48 | Created on: 4/12/2016 1:11 AM
49 | Created by: June Blender
50 | Organization: SAPIEN Technologies, Inc
51 | Filename: *.Help.Tests.ps1
52 | ===========================================================================
53 | #>
54 |
55 | #Requires -Module @{ModuleName = 'Pester'; ModuleVersion = '3.4.0'}
56 |
57 |
58 | [ValidateNotNullOrEmpty()]$Manifest = Get-ChildItem $PSScriptRoot\..\*.psd1 -Recurse
59 | $ModuleName = $Manifest.BaseName
60 | [ValidateNotNullOrEmpty()]$RequiredVersion = ($Manifest | Select-String -Pattern "^ModuleVersion = '([\d\.]*)'$").Matches.Groups.value[1]
61 |
62 |
63 | <#
64 | .SYNOPSIS
65 | Gets command parameters; one per name. Prefers default parameter set.
66 |
67 | .DESCRIPTION
68 | Gets one CommandParameterInfo object for each parameter in the specified
69 | command. If a command has more than one parameter with the same name, this
70 | function gets the parameters in the default parameter set, if one is specified.
71 |
72 | For example, if a command has two parameter sets:
73 | Name, ID (default)
74 | Name, Path
75 | This function returns:
76 | Name (default), ID Path
77 |
78 | This function is used to get parameters for help and for help testing.
79 |
80 | .PARAMETER Command
81 | Enter a CommandInfo object, such as the object that Get-Command returns. You
82 | can also pipe a CommandInfo object to the function.
83 |
84 | This parameter takes a CommandInfo object, instead of a command name, so
85 | you can use the parameters of Get-Command to specify the module and version
86 | of the command.
87 |
88 | .EXAMPLE
89 | PS C:\> Get-ParametersDefaultFirst -Command (Get-Command New-Guid)
90 | This command uses the Command parameter to specify the command to
91 | Get-ParametersDefaultFirst
92 |
93 | .EXAMPLE
94 | PS C:\> Get-Command New-Guid | Get-ParametersDefaultFirst
95 | You can also pipe a CommandInfo object to Get-ParametersDefaultFirst
96 |
97 | .EXAMPLE
98 | PS C:\> Get-ParametersDefaultFirst -Command (Get-Command BetterCredentials\Get-Credential)
99 | You can use the Command parameter to specify the CommandInfo object. This
100 | command runs Get-Command module-qualified name value.
101 |
102 | .EXAMPLE
103 | PS C:\> $ModuleSpec = @{ModuleName='BetterCredentials';RequiredVersion=4.3}
104 | PS C:\> Get-Command -FullyQualifiedName $ModuleSpec | Get-ParametersDefaultFirst
105 | This command uses a Microsoft.PowerShell.Commands.ModuleSpecification object to
106 | specify the module and version. You can also use it to specify the module GUID.
107 | Then, it pipes the CommandInfo object to Get-ParametersDefaultFirst.
108 | #>
109 | function Get-ParametersDefaultFirst {
110 | Param
111 | (
112 | [Parameter(Mandatory = $true,
113 | ValueFromPipeline = $true)]
114 | [System.Management.Automation.CommandInfo]
115 | $Command
116 | )
117 |
118 | BEGIN {
119 | $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable'
120 | $parameters = @()
121 | }
122 | PROCESS {
123 | if ($defaultPSetName = $Command.DefaultParameterSet) {
124 | $defaultParameters = ($Command.ParameterSets | Where-Object Name -eq $defaultPSetName).parameters | Where-Object Name -NotIn $common
125 | $otherParameters = ($Command.ParameterSets | Where-Object Name -ne $defaultPSetName).parameters | Where-Object Name -NotIn $common
126 |
127 | $parameters += $defaultParameters
128 | if ($parameters -and $otherParameters) {
129 | $otherParameters | ForEach-Object {
130 | if ($_.Name -notin $parameters.Name) {
131 | $parameters += $_
132 | }
133 | }
134 | $parameters = $parameters | Sort-Object Name
135 | }
136 | }
137 | else {
138 | $parameters = $Command.ParameterSets.Parameters | Where-Object Name -NotIn $common | Sort-Object Name -Unique
139 | }
140 |
141 |
142 | return $parameters
143 | }
144 | END { }
145 | }
146 |
147 | <#
148 | .SYNOPSIS
149 | Gets the module/snapin name and version for a command.
150 |
151 | .DESCRIPTION
152 | This function takes a CommandInfo object (the type that
153 | Get-Command returns) and retuns a custom object with the
154 | following properties:
155 |
156 | -- [string] $CommandName
157 | -- [string] $ModuleName (or PSSnapin name)
158 | -- [string] $ModuleVersion (or PowerShell Version)
159 |
160 | .PARAMETER CommandInfo
161 | Specifies a Commandinfo object, e.g. (Get-Command Get-Item).
162 |
163 | .EXAMPLE
164 | PS C:\> Get-CommandVersion -CommandInfo (Get-Command Get-Help)
165 |
166 | CommandName ModuleName Version
167 | ----------- ---------- -------
168 | Get-Help Microsoft.PowerShell.Core 3.0.0.0
169 |
170 | This command gets information about a cmdlet in a PSSnapin.
171 |
172 |
173 | .EXAMPLE
174 | PS C:\> Get-CommandVersion -CommandInfo (Get-Command New-JobTrigger)
175 |
176 | CommandName ModuleName Version
177 | ----------- ---------- -------
178 | New-JobTrigger PSScheduledJob 1.1.0.0
179 |
180 | This command gets information about a cmdlet in a module.
181 | #>
182 | function Get-CommandVersion {
183 | Param
184 | (
185 | [Parameter(Mandatory = $true)]
186 | [System.Management.Automation.CommandInfo]
187 | $CommandInfo
188 | )
189 |
190 | if ((-not ((($commandModuleName = $CommandInfo.Module.Name) -and ($commandVersion = $CommandInfo.Module.Version)) -or
191 | (($commandModuleName = $CommandInfo.PSSnapin) -and ($commandVersion = $CommandInfo.PSSnapin.Version))))) {
192 | Write-Error "For $($CommandInfo.Name) : Can't find PSSnapin/module name and version"
193 | }
194 | else {
195 | # "For $commandName : Module is $commandModuleName. Version is $commandVersion"
196 | [PSCustomObject]@{ CommandName = $CommandInfo.Name; ModuleName = $commandModuleName; Version = $commandVersion }
197 | }
198 | }
199 |
200 |
201 | if (!$RequiredVersion) {
202 | $RequiredVersion = (Get-Module $ModuleName -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1).Version
203 | }
204 |
205 | # Remove all versions of the module from the session. Pester can't handle multiple versions.
206 | Get-Module $ModuleName | Remove-Module
207 |
208 | # Import the required version
209 | Import-Module $Manifest -RequiredVersion $RequiredVersion -ErrorAction Stop
210 | $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]@{ ModuleName = $ModuleName; RequiredVersion = $RequiredVersion }
211 | $commands = Get-Command -FullyQualifiedModule $ms -CommandType Cmdlet, Function, Workflow # Not alias
212 |
213 | ## When testing help, remember that help is cached at the beginning of each session.
214 | ## To test, restart session.
215 |
216 | foreach ($command in $commands) {
217 | $commandName = $command.Name
218 |
219 | # Get the module name and version of the command. Used in the Describe name.
220 | $commandModuleVersion = Get-CommandVersion -CommandInfo $command
221 |
222 | # The module-qualified command fails on Microsoft.PowerShell.Archive cmdlets
223 | $Help = Get-Help $ModuleName\$commandName -ErrorAction SilentlyContinue
224 | if ($Help.Synopsis -like '*`[``]*') {
225 | $Help = Get-Help $commandName -ErrorAction SilentlyContinue
226 | }
227 |
228 | Describe "Test help for $commandName in $($commandModuleVersion.ModuleName) ($($commandModuleVersion.Version))" {
229 |
230 | # If help is not found, synopsis in auto-generated help is the syntax diagram
231 | It "should not be auto-generated" {
232 | $Help.Synopsis | Should Not BeLike '*`[``]*'
233 | }
234 |
235 | # Should be a synopsis for every function
236 | It "gets synopsis for $commandName" {
237 | $Help.Synopsis | Should Not beNullOrEmpty
238 | }
239 |
240 | # Should be a description for every function
241 | It "gets description for $commandName" {
242 | $Help.Description | Should Not BeNullOrEmpty
243 | }
244 |
245 | # Should be at least one example
246 | It "gets example code from $commandName" {
247 | ($Help.Examples.Example | Select-Object -First 1).Code | Should Not BeNullOrEmpty
248 | }
249 |
250 | # Should be at least one example description
251 | It "gets example help from $commandName" {
252 | ($Help.Examples.Example.Remarks | Select-Object -First 1).Text | Should Not BeNullOrEmpty
253 | }
254 |
255 | Context "Test parameter help for $commandName" {
256 |
257 | $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable',
258 | 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable'
259 |
260 | # Get parameters. When >1 parameter with same name,
261 | # get parameter from the default parameter set, if any.
262 | $parameters = Get-ParametersDefaultFirst -Command $command
263 |
264 | $parameterNames = $parameters.Name
265 | $HelpParameterNames = $Help.Parameters.Parameter.Name | Sort-Object -Unique
266 |
267 | foreach ($parameter in $parameters) {
268 | $parameterName = $parameter.Name
269 | $parameterHelp = $Help.parameters.parameter | Where-Object Name -EQ $parameterName
270 |
271 | # Should be a description for every parameter
272 | if ($parameterName -ne 'Confirm' -AND $parameterName -ne 'WhatIf')
273 | {
274 | It "gets help for parameter: $parameterName : in $commandName" {
275 | $parameterHelp.Description.Text | Should Not BeNullOrEmpty
276 | }
277 | }
278 |
279 | # Required value in Help should match IsMandatory property of parameter
280 | It "help for $parameterName parameter in $commandName has correct Mandatory value" {
281 | $codeMandatory = $parameter.IsMandatory.toString()
282 | $parameterHelp.Required | Should Be $codeMandatory
283 | }
284 |
285 | # Parameter type in Help should match code
286 | It "help for $commandName has correct parameter type for $parameterName" {
287 | $codeType = $parameter.ParameterType.Name
288 | # To avoid calling Trim method on a null object.
289 | $helpType = if ($parameterHelp.parameterValue) { $parameterHelp.parameterValue.Trim() }
290 | $helpType | Should be $codeType
291 | }
292 | }
293 |
294 | foreach ($helpParm in $HelpParameterNames) {
295 | # Shouldn't find extra parameters in help.
296 | It "finds help parameter in code: $helpParm" {
297 | $helpParm -in $parameterNames | Should Be $true
298 | }
299 | }
300 | }
301 | }
302 |
303 | Describe "$CommandName : URL links should be valid" -Tag Links {
304 | $Links = $help.relatedLinks.navigationLink.uri | Where-Object { ($_ -ne '') -AND ($_ -ne $Null) }
305 |
306 | foreach ($Link in $Links)
307 | {
308 | # Uri returns OK. Doesn't verify content
309 | It "[$Link] has 200 status code" {
310 | $Results = Invoke-WebRequest -Uri $Link -UseBasicParsing
311 | $Results.StatusCode | Should Be '200'
312 | }
313 | }
314 | }
315 | }
316 |
--------------------------------------------------------------------------------
/Tests/Module.Links.Tests.ps1:
--------------------------------------------------------------------------------
1 | #TODO: Convert to PoshSpec
2 |
3 | $Links = @()
4 | $MarkdownLinks = Get-ChildItem $PSScriptRoot\..\* -Include '*.md' -Recurse | Select-String '^.*\[.*\]\((http.*)\).*$' -AllMatches
5 | foreach ($Match in $MarkdownLinks)
6 | {
7 | $Links += @{$Match.Matches.Groups.value[1] = $Match.Path}
8 | }
9 |
10 |
11 | $Files = $Links.Values | Sort-Object -Unique
12 |
13 |
14 | Describe "Testing Resources" {
15 |
16 | foreach ($File in $Files)
17 | {
18 | Context "Testing Links: [$($File)]" {
19 | $FileLinks = $Links | Where-Object { $_.Values -eq $File}
20 |
21 | foreach ($Link in $FileLinks)
22 | {
23 | $Link = ($Link.Keys | Out-String).Trim()
24 |
25 | It "[$($Link)] should have 200 Status Code" {
26 |
27 | $Results = Invoke-WebRequest -Uri $Link -UseBasicParsing
28 | $Results.StatusCode | Should Be '200'
29 | }
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Tests/Resolve-TeamviewerConfigPath.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 | InModuleScope 'Posh-Teamviewer' {
5 |
6 | Describe 'Resolve-TeamviewerConfigPath' {
7 |
8 | Context 'Returns Config Directory' {
9 |
10 | It 'global variable should not be present' {
11 | $Results = Test-Path variable:Global:TeamviewerConfigPath
12 | $Results | Should be $false
13 | }
14 |
15 | $Results = Resolve-TeamviewerConfigPath
16 |
17 | It 'Should create global variable' {
18 | $PathResults = Test-Path variable:Global:TeamviewerConfigPath
19 | $PathResults | Should Be $true
20 | }
21 |
22 | It 'Should Return Directory' {
23 | $Results | Should Be "$env:APPDATA\Teamviewer"
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Tests/Set-TeamviewerAccessToken.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 | InModuleScope 'Posh-Teamviewer' {
5 |
6 | Describe 'Set-TeamviewerAccessToken' {
7 | $AccessToken = ConvertTo-SecureString -String 'Fake-AccessTokenText123456789' -AsPlainText -Force
8 | $MasterPassword = ConvertTo-SecureString -String 'FakePassword' -AsPlainText -Force
9 |
10 | Context 'AppData Teamviewer Folder Exists' {
11 | Mock Test-Path { Return $true }
12 | Mock New-Item {}
13 | Mock Set-Content {}
14 |
15 | Set-TeamviewerAccessToken -AccessToken $AccessToken -MasterPassword $MasterPassword
16 |
17 | It 'Should not Create Directory' {
18 | Assert-MockCalled New-Item -Times 0
19 | }
20 | }
21 |
22 | Context 'AppData Teamviewer Folder Missing' {
23 | Mock Test-Path { Return $false }
24 | Mock New-Item {}
25 | Mock Set-Content {}
26 |
27 | Set-TeamviewerAccessToken -AccessToken $AccessToken -MasterPassword $MasterPassword
28 |
29 | It 'Should Create Directory' {
30 | Assert-MockCalled New-Item -Times 1
31 | }
32 | }
33 |
34 | Context 'Creates Access Token files in Folder' {
35 | $TestPath = Join-Path -Path 'TestDrive:\' -ChildPath 'Teamviewer'
36 | Mock Resolve-TeamviewerConfigPath { Return $TestPath }
37 |
38 | Set-TeamviewerAccessToken -AccessToken $AccessToken -MasterPassword $MasterPassword
39 |
40 | It 'Should create api.key' {
41 | $Results = Test-Path "$TestPath\api.key"
42 | $Results | Should be $True
43 | }
44 |
45 | It 'Should create salt.rnd' {
46 | $Results = Test-Path "$TestPath\salt.rnd"
47 | $Results | Should be $True
48 | }
49 |
50 | It 'Should Return False' {
51 | $Results = Test-Path -LiteralPath "$TestPath\Fake.txt"
52 | $Results | Should be $False
53 | }
54 |
55 | It 'Salt should be 32 in length' {
56 | $Results = Get-item "$TestPath\salt.rnd"
57 | $Results.length | Should be 32
58 | }
59 | }
60 | }
61 | }
62 |
63 |
64 |
--------------------------------------------------------------------------------
/Tests/Set-TeamviewerDeviceList.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 | $Json = @"
5 | {
6 | "devices":[
7 | {
8 | "remotecontrol_id":"r123456789",
9 | "device_id":"d12345678",
10 | "alias":"Device1",
11 | "groupid":"g1234567",
12 | "online_state":"Online",
13 | "supported_features":"remote_control, chat",
14 | "description":"Test Device 1"
15 | },
16 | {
17 | "remotecontrol_id":"r987654321",
18 | "device_id":"d87654321",
19 | "alias":"Device2",
20 | "groupid":"g7654321",
21 | "online_state":"Offline",
22 | "supported_features":"chat",
23 | "description":"Test Device 2"
24 | },
25 | {
26 | "remotecontrol_id":"r987612345",
27 | "device_id":"d87612345",
28 | "alias":"Device3",
29 | "groupid":"g7612345",
30 | "online_state":"Online",
31 | "supported_features":"remote_control",
32 | "description":"Test Device 3"
33 | }
34 | ]
35 | }
36 | "@
37 |
38 | $MockedResults = $Json | ConvertFrom-Json
39 |
40 | $Global:TeamviewerAccessToken = $null
41 |
42 | InModuleScope 'Posh-Teamviewer' {
43 |
44 | Describe 'Set-TeamviewerDeviceList' {
45 | $AccessToken = ConvertTo-SecureString -String 'Fake-AccessTokenText123456789' -AsPlainText -Force
46 |
47 | Context 'Sets Global Variable' {
48 | Mock Invoke-RestMethod { Return $MockedResults }
49 |
50 | It 'Global Access Token Should not match' {
51 | $Results = $Global:TeamviewerAccessToken
52 | $Results | Should Not Be $AccessToken
53 | }
54 |
55 | $Results = Set-TeamviewerDeviceList -AccessToken $AccessToken
56 |
57 | It 'Should create global variable' {
58 | $PathResults = Test-Path variable:Global:TeamviewerDeviceList
59 | $PathResults | Should Be $true
60 | }
61 |
62 | It 'Should not throw' {
63 | $Results = { Set-TeamviewerDeviceList -AccessToken $AccessToken }
64 | $Results | Should Not Throw
65 | }
66 | }
67 |
68 | Context 'Rest-Method Returns an Error' {
69 | Mock ConvertFrom-Json {}
70 | Mock Invoke-RestMethod { Get-Content -Path .\Fakepath.txt -ErrorVariable TVError }
71 |
72 | It 'Should Throw TVError' {
73 | $Results = { Set-TeamviewerDeviceList -AccessToken $AccessToken }
74 | $Results | Should Throw
75 | }
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/Tests/Update-TeamviewerDevice.Tests.ps1:
--------------------------------------------------------------------------------
1 | Import-Module Pester -ErrorAction Stop
2 | Import-Module $PSScriptRoot\..\Posh-Teamviewer\Posh-TeamViewer.psd1
3 |
4 |
5 | InModuleScope 'Posh-Teamviewer' {
6 |
7 | Describe 'Update-TeamviewerDevice' {
8 | $AccessToken = ConvertTo-SecureString -String 'Fake-AccessTokenText123456789' -AsPlainText -Force
9 | $Password = 'FakePassword'
10 |
11 | Context 'Updates Device Description and Alias' {
12 | $MockedDeviceId = 'r123456789'
13 | $Description = 'Test Lab Device 1'
14 | $Alias = 'Test1 (Test Lab)'
15 | Mock Get-TeamviewerDeviceProperty { Return $MockedDeviceId } -Verifiable
16 | Mock Set-TeamviewerDeviceList {}
17 | Mock Invoke-RestMethod { Return ($Body | ConvertFrom-Json) } -Verifiable
18 |
19 | $Results = Update-TeamviewerDevice -ComputerName 'Test1' -Description $Description -Alias $Alias -AccessToken $AccessToken
20 |
21 | It 'Should Return Proper Json Description' {
22 | $Results.Description | Should Be $Description
23 | }
24 |
25 | It 'Should Return Proper Json Alias' {
26 | $Results.Alias | Should Be $Alias
27 | }
28 |
29 | It 'Should Not Set Device List' {
30 | Assert-MockCalled Set-TeamviewerDeviceList -Times 0
31 | }
32 |
33 | It "Should Assert Mocks" {
34 | Assert-VerifiableMocks
35 | }
36 |
37 | It 'Should Return DeviceId' {
38 | Get-TeamviewerDeviceProperty -ComputerName 'Test1' | Should Be $MockedDeviceId
39 | }
40 | }
41 |
42 | Context 'Updates Password with Update Switch' {
43 | $MockedDeviceId = 'r123456789'
44 | Mock Get-TeamviewerDeviceProperty { Return $MockedDeviceId } -Verifiable
45 | Mock Set-TeamviewerDeviceList {} -Verifiable
46 | Mock Invoke-RestMethod { Return ($Body | ConvertFrom-Json) } -Verifiable
47 |
48 | $Results = Update-TeamviewerDevice -ComputerName 'Test1' -Password $Password -AccessToken $AccessToken -UpdateDeviceList
49 |
50 | It 'Should Return Proper Json Password' {
51 | $Results.Password | Should Be $Password
52 | }
53 |
54 | It 'Should Set Device List' {
55 | Assert-MockCalled Set-TeamviewerDeviceList -Times 1
56 | }
57 |
58 | It "Should Assert Mocks" {
59 | Assert-VerifiableMocks
60 | }
61 |
62 | It 'Should Return DeviceId' {
63 | Get-TeamviewerDeviceProperty -ComputerName 'Test1' | Should Be $MockedDeviceId
64 | }
65 | }
66 |
67 | Context 'Rest-Method Returns an Error' {
68 | $MockedDeviceId = 'r123456789'
69 | Mock Get-TeamviewerDeviceProperty { Return $MockedDeviceId } -Verifiable
70 | Mock ConvertFrom-Json {} -Verifiable
71 | Mock Invoke-RestMethod { Get-Content -Path .\Fakepath.txt -ErrorVariable TVError -ErrorAction SilentlyContinue } -Verifiable
72 |
73 | It 'Should Throw TVError' {
74 | $Results = { Update-TeamviewerDevice -ComputerName 'Test1' -Password $Password -AccessToken $AccessToken }
75 | $Results | Should Throw
76 | }
77 |
78 | It 'Should Assert Mocks' {
79 | Assert-VerifiableMocks
80 | }
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | environment:
2 | NuGetApiKey:
3 | secure: JCSjKbmeUc+H++B2Ir3UaBL/XgnL9qAyPO++t5xrfCW9ku62GhkGx4XUx59Q7PqT
4 |
5 | # Allow WMF5 (i.e. PowerShellGallery functionality)
6 | os: WMF 5
7 |
8 | install:
9 | - ps: Get-PackageProvider -Name NuGet -ForceBootstrap
10 | - ps: Install-Module Pester -MinimumVersion '3.4.0' -force
11 | - ps: Install-Module Psake, PSDeploy, BuildHelpers, PlatyPS, PSScriptAnalyzer -force
12 | - ps: Import-Module Psake, BuildHelpers, PlatyPS, PSDeploy, Pester -force
13 |
14 | skip_commits:
15 | message: /updated readme.*|update readme.*s/
16 |
17 | build: false
18 |
19 | #before_test:
20 | # - ps: . .\Build.ps1
21 |
22 | test_script:
23 | - ps: Invoke-psake .\Build.Psake.ps1
24 |
25 | notifications:
26 | - provider: Slack
27 | auth_token:
28 | secure: G3SrU451ukZ4Lk+Olg0mhRcGLjfBR5l63MRUf4+pJhAs4o3iXy/BnMyiOvwWfVIiBSQNbfa943IogNY91Whj8w==
29 | channel: general
--------------------------------------------------------------------------------
/docs/Commands/Connect-Teamviewer.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: Posh-Teamviewer-help.xml
3 | schema: 2.0.0
4 | ---
5 |
6 | # Connect-Teamviewer
7 | ## SYNOPSIS
8 | Connects to a Teamviewer Device
9 | ## SYNTAX
10 |
11 | ### List (Default)
12 | ```
13 | Connect-Teamviewer -ComputerName -Password []
14 | ```
15 |
16 | ### Update
17 | ```
18 | Connect-Teamviewer -ComputerName -Password [-UpdateDeviceList]
19 | [-AccessToken ] []
20 | ```
21 |
22 | ## DESCRIPTION
23 | Connects to a Teamviewer Device using ComputerName.
24 |
25 | Requires a Teamviewer Access Token to be set via Set-TeamviewerAccessToken. If in a new PowerShell Session, you can load a saved Access Token with Initialize-Teamviewer.
26 | ## EXAMPLES
27 |
28 | ### -------------------------- EXAMPLE 1 --------------------------
29 | ```
30 | PS C:\> Connect-Teamviewer -ComputerName 'TestName' -Password $SecureString
31 | ```
32 |
33 | Connects to Teamviewer device using supplied password as Secure String.
34 | ### -------------------------- EXAMPLE 2 --------------------------
35 | ```
36 | PS C:\> Connect-Teamviewer -ComputerName 'TestName'
37 | ```
38 |
39 | Connects to Teamviewer device and prompts the User to enter the Device Password.
40 | ### -------------------------- EXAMPLE 3 --------------------------
41 | ```
42 | PS C:\> $ComputerList = @('Test1','Test2')
43 | PS C:\> Connect-Teamviewer -ComputerName $ComputerList
44 | ```
45 |
46 | Connects to Teamviewer devices Test1 and Test2 and prompts the User to enter the Device Password.
47 | ### -------------------------- EXAMPLE 4 --------------------------
48 | ```
49 | PS C:\> Connect-Teamviewer -ComputerName 'Test'
50 | ```
51 |
52 | The user is prompted to select a Device from a list of Matches of Devices with the word 'Test' in the name.
53 | ### -------------------------- EXAMPLE 5 --------------------------
54 | ```
55 | PS C:\> Connect-Teamviewer -ComputerName 'TestName' -UpdateDeviceList
56 | ```
57 |
58 | Updates the stored Device list before connecting to the Device. Requires the Teamviewer AccessToken to be set using Set-TeamviewerAccessToken or Initialize-Teamviewer to load a previously saved one.
59 | ## PARAMETERS
60 |
61 | ### -AccessToken
62 | The Teamviewer Access Token.
63 |
64 |
65 |
66 | ```yaml
67 | Type: SecureString
68 | Parameter Sets: Update
69 | Aliases:
70 |
71 | Required: False
72 | Position: Named
73 | Default value:
74 | Accept pipeline input: False
75 | Accept wildcard characters: False
76 | ```
77 |
78 | ### -ComputerName
79 | The name or the alias of the Device to be connected to.
80 |
81 |
82 |
83 | ```yaml
84 | Type: String[]
85 | Parameter Sets: (All)
86 | Aliases:
87 |
88 | Required: True
89 | Position: Named
90 | Default value:
91 | Accept pipeline input: False
92 | Accept wildcard characters: False
93 | ```
94 |
95 | ### -Password
96 | The Teamviewer Device password.
97 |
98 |
99 |
100 | ```yaml
101 | Type: SecureString
102 | Parameter Sets: (All)
103 | Aliases:
104 |
105 | Required: True
106 | Position: Named
107 | Default value:
108 | Accept pipeline input: False
109 | Accept wildcard characters: False
110 | ```
111 |
112 | ### -UpdateDeviceList
113 | Update the Devices List Global Variable that the Device information is stored. Teamviewer accounts with a large device list can take a very long time to send a response back with Device Ids. To get around this Device information is gathered and stored when Initialize-Teamviewer is ran to decrypt the Teamviewer Access Token. This allows quick Device information look up.
114 |
115 |
116 |
117 | ```yaml
118 | Type: SwitchParameter
119 | Parameter Sets: Update
120 | Aliases:
121 |
122 | Required: False
123 | Position: Named
124 | Default value:
125 | Accept pipeline input: False
126 | Accept wildcard characters: False
127 | ```
128 |
129 | ### CommonParameters
130 | 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).
131 | ## INPUTS
132 |
133 | ### System.String[]
134 |
135 | ## OUTPUTS
136 |
137 | ### System.Object
138 |
139 | ## NOTES
140 | Before you can use this Command you need to set you Teamviewer AccessToken with Set-TeamviewerAccessToken or load a previously saved AccessToken with Initialize-Teamviewer.
141 | ## RELATED LINKS
142 |
143 | [Online Version](http://posh-teamviewer.readthedocs.io/en/latest/Commands/Connect-Teamviewer/)
144 |
145 | [Markdown Version](https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Connect-Teamviewer.md)
146 |
147 | [Documentation](https://readthedocs.org/projects/posh-teamviewer/)
148 |
149 | [PSGallery](https://www.powershellgallery.com/packages/posh-teamviewer/)
150 |
151 | [Create Teamviewer Access Token](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript)
152 |
153 | [Teamviewer Api Documentation](https://integrate.teamviewer.com/en/develop/api/)
154 |
155 |
156 |
157 |
158 |
--------------------------------------------------------------------------------
/docs/Commands/Initialize-Teamviewer.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: Posh-Teamviewer-help.xml
3 | schema: 2.0.0
4 | ---
5 |
6 | # Initialize-Teamviewer
7 | ## SYNOPSIS
8 | Reads the Teamviewer AccessToken stored in the Users Appdata Folder and creates a DeviceList.
9 | ## SYNTAX
10 |
11 | ```
12 | Initialize-Teamviewer [-MasterPassword] []
13 | ```
14 |
15 | ## DESCRIPTION
16 | Reads the Teamviewer AccessToken stored in the Users $env:Appdata\Teamviewer Folder and sets a Global variable with it's SecureString value. Queries the Teamviewer Api to create a Device List and stores it as a Global variable.
17 | ## EXAMPLES
18 |
19 | ### -------------------------- EXAMPLE 1 --------------------------
20 | ```
21 | PS C:\> Initialize-Teamviewer -MasterPassword $SecureString
22 | ```
23 |
24 | Reads the Teamviewer AccessToken and sets the $Global:TeamviewerAccessToken variable with it's SecureString Value. Builds a Device List and sets it as $Global:TeamviewerDeviceList Variable
25 | ### -------------------------- EXAMPLE 2 --------------------------
26 | ```
27 | PS C:\> Initialize-Teamviewer
28 | ```
29 |
30 | Prompts the user for their MasterPassword and then reads the Teamviewer AccessToken and sets the `$Global:TeamviewerAccessToken variable. Builds a Device List and sets it as $Global:TeamviewerDeviceList Variable
31 | ## PARAMETERS
32 |
33 | ### -MasterPassword
34 | The Master Password the AccessToken was Encrypted with using Set-TeamviewerAccessToken.
35 |
36 |
37 |
38 | ```yaml
39 | Type: SecureString
40 | Parameter Sets: (All)
41 | Aliases:
42 |
43 | Required: True
44 | Position: 0
45 | Default value:
46 | Accept pipeline input: True (ByPropertyName)
47 | Accept wildcard characters: False
48 | ```
49 |
50 | ### CommonParameters
51 | 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).
52 | ## INPUTS
53 |
54 | ### System.Security.SecureString
55 |
56 | ## OUTPUTS
57 |
58 | ### System.Object
59 |
60 | ## NOTES
61 | Special thanks to Carlos Perez for the AccessToken Encryption Code.
62 | ## RELATED LINKS
63 |
64 | [Online Version](http://posh-teamviewer.readthedocs.io/en/latest/Commands/Initialize-Teamviewer/)
65 |
66 | [Markdown Version](https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Initialize-Teamviewer.md)
67 |
68 | [Documentation](https://readthedocs.org/projects/posh-teamviewer/)
69 |
70 | [PSGallery](https://www.powershellgallery.com/packages/posh-teamviewer/)
71 |
72 | [Carlos Perez Github](https://github.com/darkoperator)
73 |
74 | [Create Teamviewer Access Token](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript)
75 |
76 | [Teamviewer Api Documentation:](https://integrate.teamviewer.com/en/develop/api/)
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/docs/Commands/Set-TeamviewerAccessToken.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: Posh-Teamviewer-help.xml
3 | schema: 2.0.0
4 | ---
5 |
6 | # Set-TeamviewerAccessToken
7 | ## SYNOPSIS
8 | Encrypts the User's Teamviewer AccessToken and sets the SecureString value as a Global Variable.
9 | ## SYNTAX
10 |
11 | ```
12 | Set-TeamviewerAccessToken -AccessToken [-MasterPassword] []
13 | ```
14 |
15 | ## DESCRIPTION
16 | Encrypts the User's Teamviewer AccessToken with a Master Password and sets the SecureString value as $Global:TeamviewerAccessToken Variable.
17 | ## EXAMPLES
18 |
19 | ### -------------------------- EXAMPLE 1 --------------------------
20 | ```
21 | PS C:\> Set-TeamviewerAccessToken -AccessToken $SecureAccessTokenString -MasterPassword $SecureString
22 | ```
23 |
24 | Sets the AccessToken using the supplied Secure String Password.
25 | ### -------------------------- EXAMPLE 2 --------------------------
26 | ```
27 | PS C:\> Set-TeamviewerAccessToken
28 | ```
29 |
30 | Prompts the User for their Master Password and AccessToken.
31 | ## PARAMETERS
32 |
33 | ### -AccessToken
34 | The Teamviewer Access Token.
35 |
36 |
37 |
38 |
39 | ```yaml
40 | Type: SecureString
41 | Parameter Sets: (All)
42 | Aliases:
43 |
44 | Required: True
45 | Position: Named
46 | Default value:
47 | Accept pipeline input: False
48 | Accept wildcard characters: False
49 | ```
50 |
51 | ### -MasterPassword
52 | The Master Password the AccessToken will be Encrypted with.
53 |
54 |
55 |
56 |
57 | ```yaml
58 | Type: SecureString
59 | Parameter Sets: (All)
60 | Aliases:
61 |
62 | Required: True
63 | Position: 1
64 | Default value:
65 | Accept pipeline input: True (ByPropertyName)
66 | Accept wildcard characters: False
67 | ```
68 |
69 | ### CommonParameters
70 | 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).
71 | ## INPUTS
72 |
73 | ### System.Security.SecureString
74 |
75 | ## OUTPUTS
76 |
77 | ### System.Object
78 |
79 | ## NOTES
80 | Special thanks to Carlos Perez for the AccessToken Encryption Code.
81 | ## RELATED LINKS
82 |
83 | [Online Version](http://posh-teamviewer.readthedocs.io/en/latest/Commands/Set-TeamviewerAccessToken/)
84 |
85 | [Markdown Version](https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Set-TeamviewerAccessToken.md)
86 |
87 | [Documentation](https://readthedocs.org/projects/posh-teamviewer/)
88 |
89 | [PSGallery](https://www.powershellgallery.com/packages/posh-teamviewer/)
90 |
91 | [Carlos Perez Github](https://github.com/darkoperator)
92 |
93 | [Create Teamviewer Access Token](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript)
94 |
95 | [Teamviewer Api Documentation](https://integrate.teamviewer.com/en/develop/api/)
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/docs/Commands/Set-TeamviewerDeviceList.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: Posh-Teamviewer-help.xml
3 | schema: 2.0.0
4 | ---
5 |
6 | # Set-TeamviewerDeviceList
7 | ## SYNOPSIS
8 | Creates a Device List Global Variable with Teamviewer Device Information.
9 | ## SYNTAX
10 |
11 | ```
12 | Set-TeamviewerDeviceList [[-AccessToken] ] []
13 | ```
14 |
15 | ## DESCRIPTION
16 | Creates a Global Variable $Global:TeamviewerDeviceList with a Device List with Teamviewer Device Information that other commands can use without relying on the Teamviewer Api. The Teamviewer Api can be slow if querying a large number of devices.
17 | ## EXAMPLES
18 |
19 | ### -------------------------- EXAMPLE 1 --------------------------
20 | ```
21 | PS C:\> Set-TeamviewerDeviceList
22 | ```
23 |
24 | Sets the Device List Global Variable.
25 | ## PARAMETERS
26 |
27 | ### -AccessToken
28 | The Teamviewer Access Token.
29 |
30 |
31 |
32 |
33 |
34 |
35 | ```yaml
36 | Type: SecureString
37 | Parameter Sets: (All)
38 | Aliases:
39 |
40 | Required: False
41 | Position: 0
42 | Default value:
43 | Accept pipeline input: False
44 | Accept wildcard characters: False
45 | ```
46 |
47 | ### CommonParameters
48 | 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).
49 | ## INPUTS
50 |
51 | ### None
52 |
53 | ## OUTPUTS
54 |
55 | ### System.Object
56 |
57 | ## NOTES
58 |
59 | ## RELATED LINKS
60 |
61 | [Online Version](http://posh-teamviewer.readthedocs.io/en/latest/Commands/Set-TeamviewerDeviceList/)
62 |
63 | [Markdown Version](https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Set-TeamviewerDeviceList.md)
64 |
65 | [Documentation](https://readthedocs.org/projects/posh-teamviewer/)
66 |
67 | [PSGallery](https://www.powershellgallery.com/packages/posh-teamviewer/)
68 |
69 | [Create Teamviewer Access Token](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript)
70 |
71 | [Teamviewer Api Documentation:](https://integrate.teamviewer.com/en/develop/api/)
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/docs/Commands/Update-TeamviewerDevice.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: Posh-Teamviewer-help.xml
3 | schema: 2.0.0
4 | ---
5 |
6 | # Update-TeamviewerDevice
7 | ## SYNOPSIS
8 | Updates Properties of a Teamviewer Device.
9 | ## SYNTAX
10 |
11 | ```
12 | Update-TeamviewerDevice [-ComputerName] [[-Description] ] [[-Alias] ]
13 | [[-Password] ] [-UpdateDeviceList] [[-AccessToken] ] []
14 | ```
15 |
16 | ## DESCRIPTION
17 | Updates Properties of a Teamviewer Device. Those properties are Alias(Device's Name), Description, and Password.
18 | ## EXAMPLES
19 |
20 | ### -------------------------- EXAMPLE 1 --------------------------
21 | ```
22 | PS C:\> Update-TeamviewerDevice -ComputerName 'Test1' -Description 'Test Lab Device 1' -Alias 'Test1 (Test Lab)'
23 | ```
24 |
25 | This command updates the Teamviewer Description and Alias of the Device named 'Test1'.
26 | ### -------------------------- EXAMPLE 2 --------------------------
27 | ```
28 | PS C:\> Update-TeamviewerDevice -ComputerName 'Test1' -Password $NewPassword
29 | ```
30 |
31 | This command updates the Teamviewer Password of the Device named 'Test1'.
32 | ## PARAMETERS
33 |
34 | ### -AccessToken
35 | The Teamviewer AccessToken
36 |
37 |
38 |
39 |
40 |
41 |
42 | ```yaml
43 | Type: SecureString
44 | Parameter Sets: (All)
45 | Aliases:
46 |
47 | Required: False
48 | Position: 4
49 | Default value:
50 | Accept pipeline input: False
51 | Accept wildcard characters: False
52 | ```
53 |
54 | ### -Alias
55 | The new Name of the Device.
56 |
57 |
58 |
59 |
60 |
61 |
62 | ```yaml
63 | Type: String
64 | Parameter Sets: (All)
65 | Aliases:
66 |
67 | Required: False
68 | Position: 2
69 | Default value:
70 | Accept pipeline input: True (ByPropertyName)
71 | Accept wildcard characters: False
72 | ```
73 |
74 | ### -ComputerName
75 | The Name of the Device.
76 |
77 |
78 |
79 |
80 |
81 |
82 | ```yaml
83 | Type: String
84 | Parameter Sets: (All)
85 | Aliases:
86 |
87 | Required: True
88 | Position: 0
89 | Default value:
90 | Accept pipeline input: True (ByPropertyName)
91 | Accept wildcard characters: False
92 | ```
93 |
94 | ### -Description
95 | The Description of the Device.
96 |
97 |
98 |
99 |
100 |
101 |
102 | ```yaml
103 | Type: String
104 | Parameter Sets: (All)
105 | Aliases:
106 |
107 | Required: False
108 | Position: 1
109 | Default value:
110 | Accept pipeline input: True (ByPropertyName)
111 | Accept wildcard characters: False
112 | ```
113 |
114 | ### -Password
115 | The new Password for the Device. This is not the Password set by the Client, but the one saved in Teamviewer for connecting without a Password.
116 |
117 |
118 |
119 |
120 |
121 |
122 | ```yaml
123 | Type: String
124 | Parameter Sets: (All)
125 | Aliases:
126 |
127 | Required: False
128 | Position: 3
129 | Default value:
130 | Accept pipeline input: True (ByPropertyName)
131 | Accept wildcard characters: False
132 | ```
133 |
134 | ### -UpdateDeviceList
135 | Update the Devices List Global Variable that the Device information is stored. Teamviewer accounts with a large device list can take a very long time to send a response back with Device Ids. To get around this Device information is gathered and stored when Initialize-Teamviewer is ran to decrypt the Teamviewer Access Token. This allows quick Device information look up.
136 |
137 |
138 |
139 |
140 |
141 |
142 | ```yaml
143 | Type: SwitchParameter
144 | Parameter Sets: (All)
145 | Aliases:
146 |
147 | Required: False
148 | Position: Named
149 | Default value:
150 | Accept pipeline input: True (ByPropertyName)
151 | Accept wildcard characters: False
152 | ```
153 |
154 | ### CommonParameters
155 | 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).
156 | ## INPUTS
157 |
158 | ### System.String
159 | System.Management.Automation.SwitchParameter
160 | ## OUTPUTS
161 |
162 | ### System.Object
163 |
164 | ## NOTES
165 |
166 | ## RELATED LINKS
167 |
168 | [Online Version](http://posh-teamviewer.readthedocs.io/en/latest/Commands/Set-TeamviewerDeviceList/)
169 |
170 | [Markdown Version](https://github.com/gerane/Posh-Teamviewer/blob/master/docs/Commands/Set-TeamviewerDeviceList.md)
171 |
172 | [Documentation](https://readthedocs.org/projects/posh-teamviewer/)
173 |
174 | [PSGallery](https://www.powershellgallery.com/packages/posh-teamviewer/)
175 |
176 | [Create Teamviewer Access Token](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript)
177 |
178 | [Teamviewer Api Documentation:](https://integrate.teamviewer.com/en/develop/api/)
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/docs/Images/SetAccessToken.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gerane/Posh-Teamviewer/17629621e107dc41fe4dd9d432dc7712779f467b/docs/Images/SetAccessToken.gif
--------------------------------------------------------------------------------
/docs/Setup/Getting-Started.md:
--------------------------------------------------------------------------------
1 | # Posh-Teamviewer Module
2 |
3 | The Teamviewer PowerShell Module allows users to connect and edit device properties using the Teamviewer API.
4 |
5 | ## Installation
6 |
7 | Install from PSGallery.
8 |
9 | ```powershell
10 | PS> Install-Module -Name Posh-Teamviewer
11 | ```
12 |
13 | ## Set Access Token
14 |
15 | To get started create a Teamviewer script Access Token. For detailed insctructions follow this guide: [Create Script](https://integrate.teamviewer.com/en/develop/api/get-started/#createScript). You can also find the full API Documentation here: [API Documentation](https://integrate.teamviewer.com/en/develop/api/documentation/). Once you have your Access Token, use the command `Set-TeamviewerAccessToken` to store the Access Token and set the variable `$Global:TeamviewerAccessToken`. This command encrypts the AccessToken in a file located at `$env:APPDATA\Teamviewer` using PBKDF2 to derive a key with a Master Password and salt. Special thanks to [Carlos Perez](https://github.com/darkoperator) for the Code and Help associated with this. Here is an example of Setting the Access Token.
16 |
17 | ```powershell
18 | PS> Set-TeamviewerAccessToken -AccessToken '1234-SWDwf23vawef4122345asfg'
19 | ```
20 |
21 | 
22 |
23 | ## Load Saved Access Token
24 |
25 | To Load an encrypted Access Token into the Current Session, run the following Command:
26 |
27 | ```powershell
28 | PS> Initialize-Teamviewer -MasterPassword (Read-Host -AsSecureString)
29 | ```
30 |
31 | This command will set the following variables:
32 |
33 | * **$Global:TeamviewerAccessToken** - The Teamviewer Access Token.
34 | * **$Global:TeamviewerConfigPath** - The Path to the Teamviewer Appdata Folder.
35 | * **$Global:TeamviewerDeviceList** - A stored list of Device Details from the Teamviewer API.
36 |
37 | > **NOTE:** Teamviewer requires a Device ID to query that devices information. When **Initialize-Teamviewer** is used at the start of a session, it runs **Set-TeamviewerDeviceList** in the background to build an initial list of Device Details. This is to help in situations where an account has a very large number of devices attached to it. Responses could take upwards of 30 or more seconds when gathering information on thousdands of devices. **Initialize-Teamviewer** may run slightly longer than expected due to this, but keeps the time of the other commands to a minimum.
38 |
39 | ## Updating the Device List
40 |
41 | The first way To update the Device List is to use **Update-DeviceList**. If you need the Device Information to be up to date before running a specific command that relies on this list, a switch parameter `-UpdateDeviceList` is available that will update the List at the beginning of the command.
42 |
43 | ## Commands and Command Help
44 |
45 | | Command | Help |
46 | |-------------------------------|---------------------------------------------------------------------------------|
47 | | **Connect-Teamviewer** | [Connect-Teamviewer.md](../Commands/Connect-Teamviewer.md) |
48 | | **Initialize-Teamviewer** | [Initialize-Teamviewer.md](../Commands/Initialize-Teamviewer.md) |
49 | | **Set-TeamviewerAccessToken** | [Set-TeamviewerAccessToken.md](../Commands/Set-TeamviewerAccessToken.md) |
50 | | **Set-TeamviewerDeviceList** | [Set-TeamviewerDeviceList.md](../Commands/Set-TeamviewerDeviceList.md) |
51 | | **Update-TeamviewerDevice** | [Update-TeamviewerDevice.md](../Commands/Update-TeamviewerDevice.md) |
52 |
53 |
54 | ## Links
55 |
56 | - PSGallery - [Posh-Teamviewer](https://www.powershellgallery.com/packages/posh-teamviewer/)
57 | - Github - [Brandon Padgett](https://github.com/gerane)
58 | - Twitter - [@brandonpadgett](https://twitter.com/BrandonPadgett)
59 | - Website - [BrandonPadgett.com](http://brandonpadgett.com)
60 |
61 |
62 | ## License
63 |
64 | [MIT](LICENSE)
65 |
66 |
67 | ## Notes
68 |
69 | * [Carlos Perez](https://twitter.com/Carlos_Perez) for the ApiKey Encryption work.
70 | * [Stefan Stranger](https://twitter.com/sstranger) for giving me some ideas, whether he realized it or not.
71 | * [Warren Frame](https://twitter.com/psCookieMonster) for his awesome [PSDeploy](https://github.com/RamblingCookieMonster/PSDeploy) Module.
72 | * [June Blender](https://twitter.com/juneb_get_help) for her [Module Help Pester Tests](https://github.com/juneb/PowerShellHelpDeepDive)
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # Posh-TeamViewer Docs
2 |
3 | Posh-TeamViewer Documentation is using a combination of [PlatyPS](https://github.com/PowerShell/platyPS) and [ReadTheDocs](https://readthedocs.org/). This let's you right the command help once and it will create External Help, Github Markdown Help, and Help hosted on ReadTheDocs.
4 |
5 | - Help is written in Markdown in [the docs folder](https://github.com/gerane/Posh-Teamviewer/tree/Dev/docs) following a PlatyPS schema.
6 | - It then gets exported into an External Help file [Posh-Teamviewer-help.xml](https://github.com/gerane/Posh-Teamviewer/blob/Dev/Posh-Teamviewer/en-US/Posh-Teamviewer-help.xml).
7 | - When committed, ReadTheDocs then uses the [mkdocs.yml](https://github.com/gerane/Posh-Teamviewer/blob/Dev/mkdocs.yml) file to build the Documentation based on the mkdocs.yml layout.
8 |
9 | ## Contributing to Documentation
10 |
11 | If you find any corrections, typos or would like to contribute to the Documentation, you can do the following:
12 |
13 | - Clone the [Posh-Teamviewer Repo](https://github.com/gerane/Posh-Teamviewer)
14 | - Edit the Documentation Markdown in the [the docs folder](https://github.com/gerane/Posh-Teamviewer/tree/Dev/docs)
15 | - The structure of the Help Markdown Files is described in the [mkdocs.yml](https://github.com/gerane/Posh-Teamviewer/blob/Dev/mkdocs.yml)
16 | - Commit changes and submit a Pull Request.
17 |
--------------------------------------------------------------------------------
/mkdocs.yml:
--------------------------------------------------------------------------------
1 | site_name: Posh-Teamviewer Docs
2 | repo_url: https://github.com/gerane/Posh-Teamviewer
3 | theme: readthedocs
4 | pages:
5 | - Home: index.md
6 | - Getting Started: Setup/Getting-Started.md
7 | - Commands:
8 | - Set-TeamViewerAccessToken Help: Commands/Set-TeamviewerAccessToken.md
9 | - Initialize-TeamViewer Help: Commands/Initialize-Teamviewer.md
10 | - Connect-TeamViewer Help: Commands/Connect-Teamviewer.md
11 | - Set-TeamviewerDeviceList Help: Commands/Set-TeamviewerDeviceList.md
12 | - Update-TeamViewerDevice Help: Commands/Update-TeamviewerDevice.md
--------------------------------------------------------------------------------