On a kind of related note, anyone know if/how to set an alias that makes it easy to run internal CMD.EXE commands? - for instance, take the Path command...
If I enter the following at the Powershell prompt, it works, and displays the path variable: [PS] cmd.exe /c path I'd like an easy way to alias running those commands internal to cmd.exe, so I thought I'd try making an alias for the "cmd.exe /c" bit - e.g. new-alias D "cmd.exe /c" Thinking that I could then enter [PS] D path at the prompt, (it then being expanded to the original cmd.exe /c Path & produce the same result... Obviously (and unfortunately) that does not work, & just presents an error that it isn't a valid command, program or script... Any thoughts? TIA Paul G. From: James Rankin [mailto:[email protected]] Sent: 02 March 2011 15:21 To: NT System Admin Issues Subject: Re: PowerShell noob question Right, sorry for delay, was in a meeting. I was trying to use start-process to launch a hidden window and call a script in a share I tried start-process cmd.exe /c "\\server\share\filename.cmd" -WindowStyle Hidden start-process "cmd.exe /c \\server\share\filename.cmd" -WindowStyle Hidden start-process cmd.exe /c \\server\share\filename.cmd -WindowStyle Hidden and all gave the same error, where am I going wrong? I chose a bad day to start messing about with PS.... On 2 March 2011 14:27, Michael B. Smith <[email protected]> wrote: Yes. Quoting within PowerShell is an even more arcane art than it is with cmd.exe. And when you combine them! Oh my! Regards, Michael B. Smith Consultant and Exchange MVP http://TheEssentialExchange.com -----Original Message----- From: Ben Scott [mailto:[email protected]] Sent: Wednesday, March 02, 2011 9:09 AM To: NT System Admin Issues Subject: Re: PowerShell noob question On Wed, Mar 2, 2011 at 8:59 AM, James Rankin <[email protected]> wrote: >> > I tried /c, gave me an error >> >> What was the error? > > It was something like > > A positional parameter cannot be found that accepts argument > "\\server\share\scriptname.cmd" That's a PowerShell syntax error. It has nothing to do with CMD.EXE or any other external program. Your PowerShell code that attempts to call CMD is not doing so correctly. Post the code and I bet someone can figure it out. :) On Wed, Mar 2, 2011 at 9:00 AM, James Rankin <[email protected]> wrote: > The end goal is to use the enumerated group names to set some environment > variables. These environment variables are then used to help map the user's > printers (after they have logged in) Might be easier to enumerate the groups and set the environment all within PowerShell. Google finds recipes for both. -- Ben ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin -- "On two occasions...I have been asked, 'Pray, Mr Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." IMPORTANT: This email is intended for the use of the individual addressee(s) named above and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humour or irrational religious beliefs. If you are not the intended recipient, any dissemination, distribution or copying of this email is not authorised (either explicitly or implicitly) and constitutes an irritating social faux pas. Unless the word absquatulation has been used in its correct context somewhere other than in this warning, it does not have any legal or no grammatical use and may be ignored. No animals were harmed in the transmission of this email, although the kelpie next door is living on borrowed time, let me tell you. Those of you with an overwhelming fear of the unknown will be gratified to learn that there is no hidden message revealed by reading this warning backwards, so just ignore that Alert Notice from Microsoft. However, by pouring a complete circle of salt around yourself and your computer you can ensure that no harm befalls you and your pets. If you have received this email in error, please add some nutmeg and egg whites, whisk and place in a warm oven for 40 minutes. ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
