Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user = $args[0] #command line arg
- $Password = $args[1] #command line arg
- $script = $args[2]
- $passwd = convertto-securestring -AsPlainText -Force -String $Password
- $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
- $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
- #$Results = @()
- ForEach ($Computer in $Computers) {
- $NetVersion = Invoke-Command -ComputerName $Computer -Credential $Creds -FilePath C:\Users\Joseph\Documents\commercial-powershell\Get-NetVer.ps1 | Select-Object NetFXVersion | out-string
- $NetVersion = $NetVersion.replace("NetFXVersion ","").replace("------------ ","")
- $NetVersion = $NetVersion.replace("`r`n",",").replace(",,,","")
- $NetVersion = $NetVersion.replace(".NET Framework","")
- $NetVersion = $NetVersion.replace(" ","")
- $NetVersion = $NetVersion.replace(",,,","")
- $NetVersion = $NetVersion.replace(" ","")
- $computerName = $Computer
- echo $computerName`t$NetVersion
- }
- ===========================================
- <#
- Script Name : Get-NetFrameworkVersion.ps1
- Description : This script reports the various .NET Framework versions installed on the local or a remote computer.
- Author : Martin Schvartzman
- Last Update : Aug-2016
- Keywords : NETFX, Registry
- Reference : https://msdn.microsoft.com/en-us/library/hh925568
- #>
- param($ComputerName = $env:COMPUTERNAME)
- $dotNetRegistry = 'SOFTWARE\Microsoft\NET Framework Setup\NDP'
- $dotNet4Registry = 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
- $dotNet4Builds = @{
- 30319 = '.NET Framework 4.0'
- 378389 = '.NET Framework 4.5'
- 378675 = '.NET Framework 4.5.1 (8.1/2012R2)'
- 378758 = '.NET Framework 4.5.1 (8/7 SP1/Vista SP2)'
- 379893 = '.NET Framework 4.5.2'
- 380042 = '.NET Framework 4.5 and later with KB3168275 rollup'
- 393295 = '.NET Framework 4.6 (Windows 10)'
- 393297 = '.NET Framework 4.6 (NON Windows 10)'
- 394254 = '.NET Framework 4.6.1 (Windows 10)'
- 394271 = '.NET Framework 4.6.1 (NON Windows 10)'
- 394802 = '.NET Framework 4.6.2 (Windows 10 Anniversary Update)'
- 394806 = '.NET Framework 4.6.2 (NON Windows 10)'
- 460805 = '.NET Framework 4.7'
- }
- foreach($Computer in $ComputerName) {
- if($regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer)) {
- if ($netRegKey = $regKey.OpenSubKey("$dotNetRegistry")) {
- foreach ($versionKeyName in $netRegKey.GetSubKeyNames()) {
- if ($versionKeyName -match '^v[123]') {
- $versionKey = $netRegKey.OpenSubKey($versionKeyName)
- $version = [version]($versionKey.GetValue('Version', ''))
- New-Object -TypeName PSObject -Property @{
- ComputerName = $Computer
- NetFXBuild = $version.Build
- NetFXVersion = '.NET Framework ' + $version.Major + '.' + $version.Minor
- } | Select-Object NetFXVersion
- }
- }
- }
- if ($net4RegKey = $regKey.OpenSubKey("$dotNet4Registry")) {
- if(-not ($net4Release = $net4RegKey.GetValue('Release'))) {
- $net4Release = 30319
- }
- New-Object -TypeName PSObject -Property @{
- ComputerName = $Computer
- NetFXBuild = $net4Release
- NetFXVersion = $dotNet4Builds[$net4Release]
- } | Select-Object NetFXVersion
- }
- }
- }
- ===========================================
- $user = $args[0] #command line arg
- $Password = $args[1] #command line arg
- $script = $args[2]
- $passwd = convertto-securestring -AsPlainText -Force -String $Password
- $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
- $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
- #$Product = (Get-WmiObject Win32_OperatingSystem).Caption
- $Results = @()
- ForEach ($Computer in $Computers) {
- $Results += New-Object PSObject -Property @{
- "PowerShell Version" = Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock { "$($PSVersionTable.psversion)" }
- "ComputerName" = $Computer
- }
- }
- $Results
- ===========================================
- $user = $args[0] #command line arg
- $Password = $args[1] #command line arg
- $script = $args[2]
- $passwd = convertto-securestring -AsPlainText -Force -String $Password
- $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
- $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
- $Results = @()
- ForEach ($Computer in $Computers) {
- $Results += New-Object PSObject -Property @{
- ".NET Version" = Invoke-Command -ComputerName $Computer -Credential $Creds -FilePath C:\Users\Joseph\Documents\commercial-powershell\Get-NetVer3.ps1 |Select-Object Name | ft -Wrap
- "ComputerName" = $Computer
- }
- }
- $Results
- ===========================================
- $user = $args[0] #command line arg
- $Password = $args[1] #command line arg
- $script = $args[2]
- $passwd = convertto-securestring -AsPlainText -Force -String $Password
- $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$passwd
- $computers = Get-Content C:\Users\Joseph\Documents\commercial-powershell\Machines.txt
- ForEach ($Computer in $Computers) {
- $WindowsVersion = Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock { "$((get-wmiobject win32_operatingsystem |select-object Caption, ServicePackMajorVersion))" }
- $WindowsVersion = $WindowsVersion.replace("@{Caption=Microsoft Windows Server","")
- $WindowsVersion = $WindowsVersion.replace(" Enterprise ;","")
- $WindowsVersion = $WindowsVersion.replace("}","")
- $WindowsVersion = $WindowsVersion.replace("@{Caption=Microsoft® Windows Server® ","")
- $computerName = $Computer
- echo $computerName`t$WindowsVersion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement