Ok, so i have this script and everything works except that when it goes to apply the update powershell acts like it cannot find the file.
It returns the error "Failed: Exception calling “Start” with “2” argument(s): “the system cannot find the file specified”
I have verified that the file exists, the account i am using to apply it has permissions on it, I have even tried placing it locally on the machine i am running the script from and i still get the same error.
Here is my script:
function Invoke-BIOSUpdate {
[CmdletBinding()]
[OutputType([System.String])]
param(
[Parameter(ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[System.String]
$File,[Parameter(ValueFromPipeline=$true)] [ValidateNotNullOrEmpty()] [System.String[]] $Arguments ) begin { Write-Host "BIOS Update Needed. Attempting BIOS Flash Operation..." Write-Host "BIOS Update File: $File" Write-Host "BIOS Update Arguments: $Arguments`n" } process { try { $install = [System.Diagnostics.Process]::Start($File,$Arguments) $install.WaitForExit() | Out-Null Write-Host "Restarting System" Stop-Transcript Restart-Computer -Force } catch {[Exception] Write-Host "Failed: $_" } } end {}
}
Function ChangeBIOS {
$strcomputer = “computer”
$BIOS = Get-WmiObject “win32_BIOS" -computername $strcomputer
$Model = Get-wmiobject “win32_computersystem” -computername $strcomputer
#write-host ““$Model $strcomputer””
If ((($Model.Model).Trim() -eq “OptiPlex 3010”) -and (!($BIOS.SMBIOSBIOSVersion -eq “A09”)))
{
write-Output "Computer Name: " $strComputer
write-Output “Bios: Out of Date 3010”
Invoke-BIOSUpdate “\server\folder\Bios\Optiplex 30103010A09.exe” “-noreboot -nopause -forceit”}
elseif ((($Model.Model).Trim() -eq “OptiPlex 360”) -and (!($BIOS.SMBIOSBIOSVersion -eq “A07”)))
{
write-Output "Computer Name: " $strComputer
write-Output “Bios: Out of Date 360”
Invoke-BIOSUpdate “\server\folder\Bios\Optiplex 360360-A07.exe” “-noreboot -nopause -forceit”}
elseif ((($Model.Model).Trim() -eq “OptiPlex 380”) -and (!($BIOS.SMBIOSBIOSVersion -eq “A07”)))
{
write-Output "Computer Name: " $strComputer
write-Output “Bios: Out of Date 380”
Invoke-BIOSUpdate “\server\folder\Bios\Optiplex 380380-A07.exe” “-noreboot -nopause -forceit”}
elseif ((($Model.Model).Trim() -eq “OptiPlex 390”) -and (!($BIOS.SMBIOSBIOSVersion -eq “A10”)))
{
write-Output "Computer Name: " $strComputer
write-Output “Bios: Out of Date 390”
Invoke-BIOSUpdate “\server\folder\Bios\Optiplex 390390-A10.exe” “-noreboot -nopause -forceit”}
}
ChangeBIOS >> “h:\myscripts\testbios.txt”
To be completely honest I am relatively new to powershell and this script is not complete by any means but im just stuck at this point and need some guidance.
Any help would be greatly appreciated!