Advertisement
Guest User

Untitled

a guest
Jun 26th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.69 KB | None | 0 0
  1. $user = $args[0] #command line arg
  2. $Password = $args[1] #command line arg
  3. $script = $args[2]
  4. $passwd = convertto-securestring -AsPlainText -Force -String $Password
  5. $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
  6. $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
  7. #$Results = @()
  8. ForEach ($Computer in $Computers) {
  9. $NetVersion = Invoke-Command -ComputerName $Computer -Credential $Creds -FilePath C:\Users\Joseph\Documents\commercial-powershell\Get-NetVer.ps1 | Select-Object NetFXVersion | out-string
  10. $NetVersion = $NetVersion.replace("NetFXVersion ","").replace("------------ ","")
  11. $NetVersion = $NetVersion.replace("`r`n",",").replace(",,,","")
  12. $NetVersion = $NetVersion.replace(".NET Framework","")
  13. $NetVersion = $NetVersion.replace(" ","")
  14. $NetVersion = $NetVersion.replace(",,,","")
  15. $NetVersion = $NetVersion.replace(" ","")
  16. $computerName = $Computer
  17. echo $computerName`t$NetVersion
  18. }
  19.  
  20.  
  21.  
  22. ===========================================
  23.  
  24. <#
  25. Script Name : Get-NetFrameworkVersion.ps1
  26. Description : This script reports the various .NET Framework versions installed on the local or a remote computer.
  27. Author : Martin Schvartzman
  28. Last Update : Aug-2016
  29. Keywords : NETFX, Registry
  30. Reference : https://msdn.microsoft.com/en-us/library/hh925568
  31. #>
  32. param($ComputerName = $env:COMPUTERNAME)
  33. $dotNetRegistry = 'SOFTWARE\Microsoft\NET Framework Setup\NDP'
  34. $dotNet4Registry = 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
  35. $dotNet4Builds = @{
  36. 30319 = '.NET Framework 4.0'
  37. 378389 = '.NET Framework 4.5'
  38. 378675 = '.NET Framework 4.5.1 (8.1/2012R2)'
  39. 378758 = '.NET Framework 4.5.1 (8/7 SP1/Vista SP2)'
  40. 379893 = '.NET Framework 4.5.2'
  41. 380042 = '.NET Framework 4.5 and later with KB3168275 rollup'
  42. 393295 = '.NET Framework 4.6 (Windows 10)'
  43. 393297 = '.NET Framework 4.6 (NON Windows 10)'
  44. 394254 = '.NET Framework 4.6.1 (Windows 10)'
  45. 394271 = '.NET Framework 4.6.1 (NON Windows 10)'
  46. 394802 = '.NET Framework 4.6.2 (Windows 10 Anniversary Update)'
  47. 394806 = '.NET Framework 4.6.2 (NON Windows 10)'
  48. 460805 = '.NET Framework 4.7'
  49. }
  50. foreach($Computer in $ComputerName) {
  51. if($regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer)) {
  52. if ($netRegKey = $regKey.OpenSubKey("$dotNetRegistry")) {
  53. foreach ($versionKeyName in $netRegKey.GetSubKeyNames()) {
  54. if ($versionKeyName -match '^v[123]') {
  55. $versionKey = $netRegKey.OpenSubKey($versionKeyName)
  56. $version = [version]($versionKey.GetValue('Version', ''))
  57. New-Object -TypeName PSObject -Property @{
  58. ComputerName = $Computer
  59. NetFXBuild = $version.Build
  60. NetFXVersion = '.NET Framework ' + $version.Major + '.' + $version.Minor
  61. } | Select-Object NetFXVersion
  62. }
  63. }
  64. }
  65. if ($net4RegKey = $regKey.OpenSubKey("$dotNet4Registry")) {
  66. if(-not ($net4Release = $net4RegKey.GetValue('Release'))) {
  67. $net4Release = 30319
  68. }
  69. New-Object -TypeName PSObject -Property @{
  70. ComputerName = $Computer
  71. NetFXBuild = $net4Release
  72. NetFXVersion = $dotNet4Builds[$net4Release]
  73. } | Select-Object NetFXVersion
  74. }
  75. }
  76. }
  77.  
  78.  
  79. ===========================================
  80.  
  81. $user = $args[0] #command line arg
  82. $Password = $args[1] #command line arg
  83. $script = $args[2]
  84. $passwd = convertto-securestring -AsPlainText -Force -String $Password
  85. $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
  86. $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
  87. #$Product = (Get-WmiObject Win32_OperatingSystem).Caption
  88.  
  89.  
  90. $Results = @()
  91.  
  92. ForEach ($Computer in $Computers) {
  93. $Results += New-Object PSObject -Property @{
  94. "PowerShell Version" = Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock { "$($PSVersionTable.psversion)" }
  95. "ComputerName" = $Computer
  96. }
  97. }
  98.  
  99. $Results
  100.  
  101. ===========================================
  102.  
  103.  
  104. $user = $args[0] #command line arg
  105. $Password = $args[1] #command line arg
  106. $script = $args[2]
  107. $passwd = convertto-securestring -AsPlainText -Force -String $Password
  108. $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
  109. $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
  110.  
  111. $Results = @()
  112. ForEach ($Computer in $Computers) {
  113. $Results += New-Object PSObject -Property @{
  114. ".NET Version" = Invoke-Command -ComputerName $Computer -Credential $Creds -FilePath C:\Users\Joseph\Documents\commercial-powershell\Get-NetVer3.ps1 |Select-Object Name | ft -Wrap
  115. "ComputerName" = $Computer
  116. }
  117. }
  118.  
  119. $Results
  120.  
  121.  
  122. ===========================================
  123.  
  124.  
  125. $user = $args[0] #command line arg
  126. $Password = $args[1] #command line arg
  127. $script = $args[2]
  128. $passwd = convertto-securestring -AsPlainText -Force -String $Password
  129. $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
  130. $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
  131.  
  132. ForEach ($Computer in $Computers) {
  133. $WindowsVersion = Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock { "$((get-wmiobject win32_operatingsystem |select-object Caption, ServicePackMajorVersion))" }
  134. $WindowsVersion = $WindowsVersion.replace("@{Caption=Microsoft Windows Server","")
  135. $WindowsVersion = $WindowsVersion.replace(" Enterprise ;","")
  136. $WindowsVersion = $WindowsVersion.replace("}","")
  137. $WindowsVersion = $WindowsVersion.replace("@{Caption=Microsoft® Windows Server® ","")
  138.  
  139. $computerName = $Computer
  140. echo $computerName`t$WindowsVersion
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement