Long Story short Im working with multiple versions of PCs and Powershell versions, I need to install updates on as machines automated. I have a script that installs a module on windows 10 machines, and installs the modules on the other machines. I would like to check if the required modules are installed and imported, but Im new to perl and cant find anything.
print "Installing new updates\n";
my ( $osvername, $major, $minor, $id ) = Win32::GetOSVersion();
if($major == 10 )
{
my $ps_path = 'C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe';
system("$ps_path -command Set-ExecutionPolicy RemoteSigned -force");
system("$ps_path -command Install-Module PSWindowsUpdate -force");
system("$ps_path -command Import-Module PSWindowsUpdate -force");
system("$ps_path -command Get-WindowsUpdate -Install -AcceptAll");
system("$ps_path -command Set-ExecutionPolicy Default -force");
}
else
{
system("$gRootDir\\Tools\\WUInstall.exe /install");
}