Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [System.String[]]$compArray = @()
- [System.String]$compName = ""
- [System.String]$myArrayLocation = ""
- function SetMultiComp
- {
- $multipleCompTest = Read-Host 'Are You Wanting To Perform The Following Operation On Multiple Computers? y/n'
- switch($true)
- {
- ($multipleCompTest -match "y"){MultiCompOp}
- ($multipleCompTest -match "n"){SingleCompOp}
- default{Clear-Host; Write-Host "Invalid Answer"; SetMultiComp;}
- }
- }
- function MultiCompOp($myArrayLocation)
- {
- Clear-Host
- $testLoc = Read-Host 'Please Give The Location Of Your Computer List'
- if((Test-Path $testLoc) -eq $true)
- {
- Set-Variable -Name "myArrayLocation" -Value "$testLoc" -Visibility Public;
- MultiCompPrep ($myArrayLocation);
- }
- else
- {
- Clear-Host; Write-Host "File Not Found"; MultiCompOp;
- }
- }
- function MultiCompPrep($compName)
- {
- foreach($compNameInst in $myArrayLocation)
- {
- Set-Variable -Name "compName" -Value "$compNameInst" -Visibility Public;
- main ($compName);
- }
- }
- function SingleCompOp($compName)
- {
- Clear-Host
- $compNameInst = Read-Host 'What Is The Name Of The Computer You Want To Effect';
- Set-Variable -Name "compName" -Value $compNameInst -Visibility Public;
- main ($compName);
- }
- function main($compName)
- {
- $collItem = Get-WmiObject -Class Win32_OperatingSystem -ComputerName "$compName"
- Foreach($itemInst in $collItem)
- {
- $itemInst.Reboot()
- }
- }
- SetMultiComp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement