Get a list of computers, 32/64 bit architecture, Service Pack level, and IP address in active directory with PowerShell

To get an inventory .csv file list of all computers in AD, run the following command in powershell:

Make sure you import Active Directory modules into PowerShell prior to running the command.

Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion,ipv4* | Export-Csv -Path "c:\admin\ComputersList.csv"

If you first receive the following error:

“The term ‘Get-ADComputer’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”

This error indicates that the Active Directory module has not been imported into PowerShell. First do this by running the command:

import-module activedirectory

This script should produce and export a .csv file list that looks like the following:

Name OperatingSystem OperatingSystemServicePack OperatingSystemVersion IPv4Address
DC01 Windows Server 2008 R2 Standard Service Pack 1 6.1 (7601) 10.1.3.4
JasonCWKS Windows 7 Professional Service Pack 1 6.1 (7601) 10.1.2.129
JColtrinWin7 Windows 7 Professional Service Pack 1 6.1 (7601) 10.1.2.85

If you want to take this further, and get the csname (computer name), caption (Operating system title), OS Architecture (32/64 bit), and ServicePackMajorVersion (service pack level) from a list of IP’s that the previous command produced you can do the following:

  1. Copy the IP addresses of all the machines to a new file called win7pcs.txt and place it in C:\admin\
  2. Open Powershell ISE  and enter the following script:
$a = Get-Content "C:\admin\win7pcs.txt" 
foreach ($i in $a) 
{Get-WmiObject Win32_OperatingSystem -ComputerName $i | Format-Table csname,caption,OSArchitecture,ServicePackMajorVersion -AutoSize
}

This should produce the following output for each IP address:

csname caption OSArchitecture ServicePackMajorVersion
—— ——- ————– ———————–
JasonCWKS Microsoft Windows 7 Professional 64-bit 1

csname caption OSArchitecture ServicePackMajorVersion
—— ——- ————– ———————–
JcoltrinWin7 Microsoft Windows 7 Professional 32-bit 1

powershell – Find all computers in a domain or OU running a service

Sometimes you need to find all the computers on a domain that are running a certain particular service. By using Active Directory, supplying your canonical domain name, and define an output file, you can easily create a list of computers running a service.

First, start PowerShell as administrator, and import active-directory powershell components with the following command:

Import-Module ActiveDirectory

Then, open PowerShell ISE and copy in the following into a new .ps1 script:

$ou = "OU=Computers,OU=finance,DC=east,DC=contoso,DC=com"

$servers = Get-ADComputer -Filter * -SearchBase $ou | select-object 
-expandproperty name

Foreach ($server in $servers){
$Data = Get-Service -ServiceName *SAVService* -ComputerName $server | 
select machinename,name | sort machinename | format-table -AutoSize 

Write($Data) | Out-File .\machinesrunningSAVService.txt -Append
}

Run the script, and your output file will look similar to the following:

MachineName Name      
----------- ----      
hostname1   SAVService



MachineName Name      
----------- ----      
hostname2   SAVService



MachineName Name      
----------- ----      
hostname3   SAVService

Powershell – remotely copy multiple files to a list of computers

How to copy multiple files to a list of computers

PowerShell – copy a list of files to a list of multiple computers

Here is a simple PowerShell script I found (linked below) that can easily copy a list of files to a list of computers. If you want to copy more than one file to a lot of computers on your network, this simple script should work ok. It’s better to use a network share and use a UNC path to denote where the file source and destinations.

$a = Get-Content "C:\computerlist.txt" 

foreach ($i in $a) 

{$files= get-content "C:\fileslist.txt"
foreach ($file in $files)
{Copy-Item $file -Destination \\$i\C$\admin\ -force}
}

Here is a sample of what the computerlist.txt will look like:

hostname1.contoso.com
hostname2.contoso.com
hostname3.contoso.com

And here is a sample of what the fileslist.txt will look like:

\\fileserver\share\IT\myscript.ps1
\\fileserver\share\IT\Readme.txt
\\fileserver\share\IT\uninstall.bat

https://social.technet.microsoft.com/Forums/office/en-US/09575f93-7b17-4621-804d-4b018df34771/powershell-copy-a-list-of-files-to-multiple-servers-and-backup-exisiting-files?forum=winserverpowershell

Powershell – remotely copy multiple files to a list of computers

How to copy multiple files to a list of computers

PowerShell – copy a list of files to a list of multiple computers

Here is a simple PowerShell script I found (linked below) that can easily copy a list of files to a list of computers. If you want to copy more than one file to a lot of computers on your network, this simple script should work ok. It’s better to use a network share and use a UNC path to denote where the file source and destinations.

$a = Get-Content "C:\computerlist.txt" 

foreach ($i in $a) 

{$files= get-content "C:\fileslist.txt"
foreach ($file in $files)
{Copy-Item $file -Destination \\$i\C$\admin\ -force}
}

Here is a sample of what the computerlist.txt will look like:

hostname1.contoso.com
hostname2.contoso.com
hostname3.contoso.com

And here is a sample of what the fileslist.txt will look like:

\\fileserver\share\IT\myscript.ps1
\\fileserver\share\IT\Readme.txt
\\fileserver\share\IT\uninstall.bat

 

https://social.technet.microsoft.com/Forums/office/en-US/09575f93-7b17-4621-804d-4b018df34771/powershell-copy-a-list-of-files-to-multiple-servers-and-backup-exisiting-files?forum=winserverpowershell