-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Djily90/fix_empty_xml
Fix empty xml
- Loading branch information
Showing
3 changed files
with
100 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<# | ||
.SYNOPSIS | ||
This script retrieves TeamViewer's ClientID and Version from the registry | ||
and outputs the result in an XML format. | ||
.DESCRIPTION | ||
It considers both 32-bit and 64-bit OS architectures. | ||
#> | ||
|
||
$xml = $null | ||
|
||
# Declare the registry path | ||
$regPath = "" | ||
|
||
# Initialize the registry path based on the architecture | ||
if(Test-Path "HKLM:\SOFTWARE\WOW6432Node\TeamViewer") | ||
{ | ||
$regPath = "HKLM:\SOFTWARE\WOW6432Node\TeamViewer" | ||
} | ||
if(Test-Path "HKLM:\SOFTWARE\TeamViewer") | ||
{ | ||
$regPath = "HKLM:\SOFTWARE\TeamViewer" | ||
} | ||
|
||
if (Test-Path $regPath) | ||
{ | ||
# Try to get TeamViewer ClientID from the registry | ||
$teamViewer = (Get-ItemProperty -Path $regPath) | ForEach-Object { | ||
$xml += "<TEAMVIEWER>`n" | ||
$xml += "<TWID>"+ $_.Version +"</TWID>`n" | ||
$xml += "<VERSION>"+ $_.ClientID +"</VERSION>`n" | ||
$xml += "</TEAMVIEWER>`n" | ||
} | ||
} | ||
|
||
# just in case | ||
if($xml -eq $null) { | ||
$xml += "<TEAMVIEWER>`n" | ||
$xml += "<TWID>" + "No data available in table" + "</TWID>`n" | ||
$xml += "<VERSION></VERSION>`n" | ||
$xml += "</TEAMVIEWER>`n" | ||
} | ||
|
||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | ||
[Console]::WriteLine($xml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,50 @@ | ||
'---------------------------------------------------------- | ||
' Plugin for OCS Inventory NG 2.x | ||
' Script : Retrieve Teamviewer ID and version | ||
' Version : 2.00 | ||
' Date : 22/07/2017 | ||
' Authors : Valentin DEVILLE and Stéphane PAUTREL (acb78.com) | ||
'---------------------------------------------------------- | ||
' OS checked [X] on 32b 64b (Professionnal edition) | ||
' Windows XP [X] | ||
' Windows Vista [X] [X] | ||
' Windows 7 [X] [X] | ||
' Windows 8.1 [X] [X] | ||
' Windows 10 [X] [X] | ||
' Windows 2k8R2 [X] | ||
' Windows 2k12R2 [X] | ||
' Windows 2k16 [X] | ||
' --------------------------------------------------------- | ||
' NOTE : No checked on Windows 8 | ||
' --------------------------------------------------------- | ||
On Error Resume Next | ||
|
||
Set shell = WScript.CreateObject("WScript.Shell") | ||
Set objWMIService = GetObject( "winmgmts://./root/cimv2" ) | ||
Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor", , 48 ) | ||
|
||
For Each objItem in colItems | ||
ArchiOS = objItem.AddressWidth | ||
If ArchiOS = "32" Then | ||
Wow = "" | ||
ElseIf ArchiOS = "64" Then | ||
Wow = "WOW6432Node\" | ||
End If | ||
Next | ||
|
||
stReg = "HKEY_LOCAL_MACHINE\SOFTWARE\" & Wow & "TeamViewer\" | ||
Check = shell.RegRead(stReg) | ||
If Err.Number <> 0 Then Wscript.quit | ||
|
||
twID = shell.RegRead (stReg & "ClientID") | ||
twVersion = shell.RegRead (stReg & "Version") | ||
|
||
Wscript.Echo _ | ||
"<TEAMVIEWER>" & VbCrLf &_ | ||
"<TWID>" & twID & "</TWID>" & VbCrLf &_ | ||
"<VERSION>" & twVersion & "</VERSION>" & VbCrLf &_ | ||
"</TEAMVIEWER>" | ||
'---------------------------------------------------------- | ||
' Plugin for OCS Inventory NG 2.x | ||
' Script : Retrieve Teamviewer ID and version | ||
' Version : 2.00 | ||
' Date : 22/07/2017 | ||
' Authors : Valentin DEVILLE and Stéphane PAUTREL (acb78.com) | ||
'---------------------------------------------------------- | ||
' OS checked [X] on 32b 64b (Professionnal edition) | ||
' Windows XP [X] | ||
' Windows Vista [X] [X] | ||
' Windows 7 [X] [X] | ||
' Windows 8.1 [X] [X] | ||
' Windows 10 [X] [X] | ||
' Windows 2k8R2 [X] | ||
' Windows 2k12R2 [X] | ||
' Windows 2k16 [X] | ||
' --------------------------------------------------------- | ||
' NOTE : No checked on Windows 8 | ||
' --------------------------------------------------------- | ||
On Error Resume Next | ||
|
||
Set shell = WScript.CreateObject("WScript.Shell") | ||
Set objWMIService = GetObject( "winmgmts://./root/cimv2" ) | ||
Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor", , 48 ) | ||
|
||
For Each objItem in colItems | ||
ArchiOS = objItem.AddressWidth | ||
If ArchiOS = "32" Then | ||
Wow = "" | ||
ElseIf ArchiOS = "64" Then | ||
Wow = "WOW6432Node\" | ||
End If | ||
Next | ||
|
||
stReg = "HKEY_LOCAL_MACHINE\SOFTWARE\" & Wow & "TeamViewer\" | ||
Check = shell.RegRead(stReg) | ||
If Err.Number <> 0 Then Wscript.quit | ||
|
||
twID = shell.RegRead (stReg & "ClientID") | ||
twVersion = shell.RegRead (stReg & "Version") | ||
|
||
If twID = "" AND twVersion = "" Then | ||
twID = "No data available in table" | ||
End If | ||
|
||
Wscript.Echo _ | ||
"<TEAMVIEWER>" & VbCrLf &_ | ||
"<TWID>" & twID & "</TWID>" & VbCrLf &_ | ||
"<VERSION>" & twVersion & "</VERSION>" & VbCrLf &_ | ||
"</TEAMVIEWER>" |