Avatar of Carl Billington
Carl Billington
Flag for Australia asked on

Help combine my PowerShell scripts

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.
Powershell

Avatar of undefined
Last Comment
Carl Billington

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Dent

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Carl Billington

ASKER
You are a genius!
Your help has saved me hundreds of hours of internet surfing.
fblack61