![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Questions of Powershell script I just trying to write up a simple Powershell script quickly. Here're some basic questions: 1. A powershell commands can be saved in a .vbs file and run it in windows console using: cscript xyz.vbs? 2. For comment in Powershell script, add ",' in front of commands? 3. In the vbs file when adding commands like: Wscript.echo "learning powershell..." or write-host "learning Powershell..." In both cases, it gave error: "VbScript compilation error: Expected end of statement" What's wrong here? 4. This command will not work: Copy-Item testfile.txt c:\PS Test Folder But will this fixes it? $dir = "c:\PS Test Folder" Copy-Item testfile.txt $dir 5. How to start a batch file from within the vbs file? Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Questions of Powershell script "dh" wrote: > I just trying to write up a simple Powershell script quickly. Here're some > basic questions: > > 1. A powershell commands can be saved in a .vbs file and run it in windows > console using: cscript xyz.vbs? no you need to save the script as a .ps1 file and use powershell.exe > 2. For comment in Powershell script, add ",' in front of commands? # this is a comment > 3. In the vbs file when adding commands like: > > Wscript.echo "learning powershell..." > or > write-host "learning Powershell..." > > In both cases, it gave error: "VbScript compilation error: Expected end of > statement" > > What's wrong here? you're not using powershell.exe > 4. This command will not work: > > Copy-Item testfile.txt c:\PS Test Folder > > But will this fixes it? Copy-Item testfile.txt 'c:\PS Test Folder\' should work > $dir = "c:\PS Test Folder" > Copy-Item testfile.txt $dir > > 5. How to start a batch file from within the vbs file? & "C:\script\script.ps1" -- greetings dreeschkind |
My System Specs![]() |
| | #3 (permalink) |
| Guest | RE: Questions of Powershell script "dreeschkind" wrote: > "dh" wrote: > > > I just trying to write up a simple Powershell script quickly. Here're some > > basic questions: > > > > 1. A powershell commands can be saved in a .vbs file and run it in windows > > console using: cscript xyz.vbs? > > no you need to save the script as a .ps1 file and use powershell.exe > Thanks for your quick answering! Is commandline in console: powershell.exe xyz.ps1? > > 3. In the vbs file when adding commands like: > > > > Wscript.echo "learning powershell..." > > or > > write-host "learning Powershell..." > > > > In both cases, it gave error: "VbScript compilation error: Expected end of > > statement" > > > > What's wrong here? > > you're not using powershell.exe > I just did a quick test and here's the error I got: C:\pstest>powershell update.psl The term 'xyz.ps1' is not recognized as a cmdlet, function, operable program , or script file. Verify the term and try again. At line:1 char:10 + xyz.ps1 <<<< > > 5. How to start a batch file from within the vbs file? > > & "C:\script\script.ps1" > Then the question is how to start a batch file, like "abc.bat" from within xyz.ps1 file? |
My System Specs![]() |
| | #4 (permalink) |
| Guest | RE: Questions of Powershell script Just figured this one out... The commandline must be powershell.exe c:\pstest\xyz.ps1, not "powershell.exe xyz.ps1." |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Questions of Powershell script or powershell.exe .\filename.ps1 in same directory "dh" <dh@discussions.microsoft.com> wrote in message news:F658F392-A863-4BBC-A31A-9C57EC932E2E@microsoft.com... > Just figured this one out... > > The commandline must be powershell.exe c:\pstest\xyz.ps1, not > "powershell.exe xyz.ps1." |
My System Specs![]() |
| | #6 (permalink) |
| Guest | RE: Questions of Powershell script "dh" wrote: > Is commandline in console: powershell.exe xyz.ps1? to see all command line options run powershell.exe -? > > > 5. How to start a batch file from within the vbs file? > > > > & "C:\script\script.ps1" > > > > Then the question is how to start a batch file, like "abc.bat" from within > xyz.ps1 file? Sorry, this was a typo. You can start batch files and other programs directly from powershell console and powershell scripts: & "C:\script\batch.bat" & "C:\script\commands.cmd" & "C:\script\app.exe" etc. -- greetings dreeschkind |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Questions on PowerShell | SD | PowerShell | 9 | 06-11-2008 12:45 PM |
| when run powershell script as windows service ,powershell fail | powershell fail on winodws 2008 | PowerShell | 6 | 01-15-2008 03:20 PM |
| Some powershell questions... | mpriem | PowerShell | 4 | 04-02-2007 01:04 PM |
| Remote powershell - questions | Did | PowerShell | 5 | 02-26-2007 09:27 AM |
| 3 questions (Re: Vista RTM + PowerShell) | Jon Davis | PowerShell | 5 | 11-26-2006 06:50 AM |