Link to home
Create AccountLog in
VB Script

VB Script

--

Questions

--

Followers

Top Experts

Avatar of cawasaki
cawasaki

help with this line code
Hi,

i have this line code:

psexec.exe -c -h \\computer C:\Temp\BiosConfigUtility.EXE /c spwd:"" /nspwd:""

Open in new window



this command line check the bios of remote computer and perform a password change with from empty to empty, i use it to verify if computer have password or not.

if the password is not empty, i get this message:

 
<BIOSCONFIG Version="2.14.0.8" Computername="computer" Date="2013/07/25" Time=
"14:56:39" UTC="2" >
<WARNING msg="Attempt to change the password, but correct password not provided.
" />
<Warning msg="BCU return value" real="10" translated="10" />
</BIOSCONFIG>
BiosConfigUtility.EXE exited on computer with error code 10.

Open in new window


if the password is allready empty, the command line will work and change password and get this message:

<BIOSCONFIG Version="2.14.0.8" Computername="computer" Date="2013/07/25" Time=
"15:06:38" UTC="2" >
<Warning msg="BCU return value" real="0" translated="0" />
</BIOSCONFIG>
BiosConfigUtility.EXE exited on computer with error code 0.

Open in new window


i need the script to get from txt file with 100 computer and check for every one.

and exeport a result in csv file in this form:

computer,result
computer1,Attempt to change the password, but correct password not provided
computer2,BCU return value" real="0" translated="0"
computer3,Attempt to change the password, but correct password not provided
.......

in result, i need to filter the result and display only one of this 2 result:

Attempt to change the password, but correct password not provided

or

BCU return value" real="0" translated="0"



thanks for help

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of BT15BT15🇺🇸

capturing output from PSEXEC can be tricky. i think you might have to do it like this:

(powershell, btw)
& psexec.exe -c -h \\computer C:\Temp\BiosConfigUtility.EXE /c spwd:"" /nspwd:"">output.txt

Open in new window


and then collect the text file and parse out the results

i think the results from that command probably land in \\computer\c$\windows\system32\output.txt

we dont allow psexec where I am right now, so i cannot mock something up at this time... maybe one of the others has some past experience here

Avatar of footechfootech🇺🇸

This might work for you.  Haven't been able to test, but used something similar recently.
$results = @()
$str1 = 'Attempt to change the password, but correct password not provided'
$str2 = 'BCU return value" real="0" translated="0"'
foreach ($computer in (Get-Content computers.txt))
{
   $results += c:\sysinternalssuite\psexec.exe -c -h \\$computer C:\Temp\BiosConfigUtility.EXE /c spwd:"" /nspwd:"" |
 Where {$_ -match "^\<WARNING msg=(.+)(?: />|\.)$"} |
 ForEach {$matches[1] | Where {$_ -match $str1 -or $_ -match $str2}} |
    ForEach { New-Object PSObject -Property @{ Computer = $computer; result = $_ } }
}
$results | Export-CSV c:\temp\output.csv -notype

Open in new window


Avatar of BT15BT15🇺🇸

kudos, footech. i didnt think you would be able to get psexec like that because of how it behaves... but apparently you can. that should work for cawasaki's needs...

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of cawasakicawasaki

ASKER

hello,

i will test and report.

thanks for help

Avatar of footechfootech🇺🇸

Calling PsExec isn't a problem, but I don't know if we going to run into any issues with the command we're trying to run with all the switches and quotes, and I don't have any way to test.  We'll see.  :)

hello,

@footech:

its work and do what i need, but i have a problem, if computer not respond (because its not power on, or other think), all script get error:

Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\temp\test\checkbios.ps1:11 char:22
+ $results | Export-CSV <<<<  c:\temp\test\output.csv -notype
    + CategoryInfo          : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand

Open in new window


any solution? i think if possible, mark on csv that computer is power off.

thanks

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of footechfootech🇺🇸

I've added some code to try to ping each computer.
$results = @()
$str1 = 'Attempt to change the password, but correct password not provided'
$str2 = 'BCU return value" real="0" translated="0"'
foreach ($computer in (Get-Content computers.txt))
{
   If (Test-Connection $computer -count 1 -quiet)
   {
   $results += c:\sysinternalssuite\psexec.exe -c -h \\$computer C:\Temp\BiosConfigUtility.EXE /c spwd:"" /nspwd:"" |
 Where {$_ -match "^\<WARNING msg=(.+)(?: />|\.)$"} |
 ForEach {$matches[1] | Where {$_ -match $str1 -or $_ -match $str2}} |
    ForEach { New-Object PSObject -Property @{ Computer = $computer; result = $_ } }
   }
   Else { $results += New-Object PSObject -Property @{ Computer = $computer; result = "Not responding" }
   }
}
$results | Export-CSV c:\temp\output.csv -notype

Open in new window


hEllo,

at this time its work, but when i apply script for 2000 computers it have take 8 hours without complete, on screen it have stop on :

Starting PsExec service on computername1 .........

so i have exit the script, and the problem, all computer checked, i have nothing, i thing the result file will only showed after complete all computer?

no way to construct report file same time script run?

i have re test with only 500 computers and at the end i have this error, but the csv file seem to be good:

Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\temp\test\checkbios.ps1:16 char:22
+ $results | Export-CSV <<<<  c:\temp\test\output.csv -notype
    + CategoryInfo          : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand

Open in new window


thanks

ASKER CERTIFIED SOLUTION
Avatar of footechfootech🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

thank you i will test it

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


hello,

ok now i have a csv file when script is on.

but same time the script block on  Starting PsExec service on computername...
its possible to make a timout of 20 second for exemple for every psexec command to be sure if not respond it can continue? after 20sec timout, in csv file the script register not responding.

thank you

Avatar of footechfootech🇺🇸

There probably is a way, but I don't know it.

I've heard that enabling the right firewall rules can make PsExec run faster.  Try ensuring that the predefined rule "Remote Service Management (RPC)" is enabled.

Avatar of SubSunSubSun🇮🇳

I think you can use -n switch to specify the timeout values.. Try..

psexec -n 30 <rest of the command>

Open in new window


Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


thank you footech

@Subsun, thank you, i have already test with the -n option :)

Avatar of SubSunSubSun🇮🇳

Nice!.. :-)
VB Script

VB Script

--

Questions

--

Followers

Top Experts

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.