So I am doing this project which requires me to run an auditing and hardening script to detect and run on multiple vSphere host. However for now, the script that I currently have could only run on one host only. So
currently, 1 Control Machine can detect and run the script on 1 host. But
what I want is 1 Control Machine to be able to detect and run the script (snippet below) on multiple host. Is there any way I could do it using PowerShell? Or do I need to use another software/method to achieve that
Snippet of my current script
Param (
[Parameter(Mandatory=$true)][string]$s,
[Parameter(Mandatory=$true)][string]$u,
[Parameter(Mandatory=$true)][string]$p
)
function connect-server{
#Connecting to server
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
$serverin = $s
$userin = $u
$passin = $p
$error.clear()
Connect-VIServer -Server $serverin -User $userin -Password $passin
Try{
Connect-VIServer -Server $serverin -ErrorAction Stop
if($global:DefaultVIServer.IsConnected){
Write-Host "Server connected!`n" -ForegroundColor DarkGreen
do {$ask = Read-Host "Specify NTP Server, Syslog Directory, Syslog Server? (Y/N)"}
until (($ask -eq "Y") -or ($ask -eq "N")) ......
............................