by Cancerous at 2012-10-10 16:58:14
Trying to set up a script to call wsname.exe (http://mystuff.clarke.co.nz/MyStuff/wsname.asp) which renames the computer and reboots.by JeffH at 2012-10-10 18:57:14
In batch, the script looks likec:\wsname.exe /N:$SERIALNUM /REBOOT
and it is run at startup.
If I run this in powershell, it does nothing. I’ve read a bit about parameters in external commands using the & operator, but that doesn’t seem to work for me either.
Any help is appreciated.
Try:by Cancerous at 2012-10-10 20:04:46
Invoke-Expression -command "&c:\wsname.exe /N:$SERIALNUM /REBOOT"
[quote="JeffH"]Try:
Invoke-Expression -command "&c:\wsname.exe /N:$SERIALNUM /REBOOT"[/quote]Still nothing :</blockquote>by coderaven at 2012-10-11 03:48:37To run the above code you may need to escape the $ with a `,see Get-Help about_Escape_Characters, or put the entire thing in ticks ‘&C:.…’ the ampersand is telling PowerShell to just run the command.by nohandle at 2012-10-11 06:38:51
I would also consider running WMI to rename the computer.
Something like:invoke-wmimethod -Class Win32_ComputerSystem -Name Rename -ArgumentList (Get-WmiObject -Class Win32_BIOS).SerialNumber
Make sure you test the WMI method call of you want to use it.Hello,by willsteele at 2012-10-12 16:30:30
starting with Powershell v3 there will be --% operator avalilable, that stops parsing until end of line.&c:\wsname.exe --% /N:$SERIALNUM /REBOOT
[quote="nohandle"]Hello,by DonJ at 2012-10-12 16:41:38
starting with Powershell v3 there will be --% operator avalilable, that stops parsing until end of line.&c:\wsname.exe --% /N:$SERIALNUM /REBOOT
[/quote]
I am curious about this. Do you have any links talking about this new operator? I am guessing it’s an operator.A over pointed it out at TechEd, but I have not seen it in any docs yet. Probably hiding.