Can someone please help me combine multiple PowerShell scripts below. I will detail each step exactly what I action manually.
1. I run;
C:\Scripts\Pending Reboots\ServersExport.ps1
import-module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' -force
cd AVA:
$Members = Get-CMDevice -CollectionName "All Servers"
$Members | select Name | Out-File "C:\Scripts\Pending Reboots\All Servers.txt"
c:
Open in new window
2. I run;
C:\Scripts\Pending Reboots\WhiteSpaces.ps1
$content = Get-Content 'C:\Scripts\Pending Reboots\All Servers.txt'
$content | Foreach {$_.TrimEnd()} | Set-Content 'C:\Scripts\Pending Reboots\All Servers.txt'
Get-Content 'C:\Scripts\Pending Reboots\All Servers.txt' | Where-Object {$_ -notmatch 'Name'} | Set-Content 'C:\Scripts\Pending Reboots\All Servers1.txt'
Get-Content 'C:\Scripts\Pending Reboots\All Servers1.txt' | Where-Object {$_ -notmatch '----'} | Set-Content 'C:\Scripts\Pending Reboots\All Servers.txt'
remove-item -path 'C:\Scripts\Pending Reboots\All Servers1.txt' -force
Open in new window
3. I run this command:
. .\Get-PendingReboot.ps1
As per;
https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542
4. I run;
C:\Scripts\Pending Reboots\PendingRebootReport.ps1
$Servers = Get-Content 'C:\Scripts\Pending Reboots\All Servers.txt'
Get-PendingReboot -Computer $Servers | Export-Csv 'C:\Scripts\Pending Reboots\PendingRebootReport.csv' -NoTypeInformation
Open in new window
Thank you.