Hello All,
New to forum, tried search option but unable to find the question.
i Am having some troubles adapting a button in the well known lazy admin tool.
I am able to do the rest (adding scripts, adding or removing options.
No issues with this.
The specific code that i have some issues with is the following:
One of the buttons has been ajusted to retrive build number.
However i am able to execud code individual, but not in combination.
$button_remot_Click={
Get-ComputerTxtBox
Add-logs -text “Show windows build version for $ComputerName”
$OSWin32_OS = Get-WmiObject -Class Win32_OperatingSystem $ComputerName
if ($result -ne $null)
{
if ($result.ReturnValue -eq 0){
Show-MsgBox -BoxType “OKOnly” -Title “$ComputerName - OS version” -Prompt “Win version shown successfully!” -Icon “Information”
Add-RichTextBox $($result|Out-String)
}
}
else {Show-MsgBox -BoxType “OKOnly” -Title "$ComputerName - OS version " -Prompt “Win Version does not work!” -Icon “Exclamation”}
}
At $OSWin32 i have
$OSWin32_OS = Get-WmiObject -Class Win32_OperatingSystem -Namespace “root\cimv2” -ComputerName $ComputerName
Using $OSWin32 and $ComputerName are working individual (tested in Powershell ISE).
The code provide the correct output (splash screenwith error message because it does not read the command:
$OSWin32_OS = Get-WmiObject -Class Win32_OperatingSystem $ComputerName
Output when testing individual:
PS C:> Get-WmiObject -Class Win32_OperatingSystem
SystemDirectory : C:\Windows\system32
Organization :
BuildNumber : 1809
RegisteredUser : Windows User
SerialNumber : ---
Version :..****
PS C:> $OSWin32_OS = Get-WmiObject -Class Win32_OperatingSystem $ComputerName
Get-WmiObject : Value cannot be null.
Parameter name: value
At line:1 char:16
- $OSWin32_OS = Get-WmiObject -Class Win32_OperatingSystem $ComputerName
-
- CategoryInfo : NotSpecified: ( [Get-WmiObject], ArgumentNullException
- FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
PS C:>
So, this show me at least that the individual inputs are working, but in conjunction they do not.
The idea is to press a button, and that provides above information.
What can i do to get it to work? it shows the error message, i know that the error is in the in red highlighted bit.
the rest works ok.
thank you for pointing me to the correct location.