![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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
Posts: n/a
| dos command in powershell Hi there, as suggested to me a few days ago, i'm trying to make a "net use \\printerserver" into my ps1 scripts, but don't succeed; my command line i try to use is $chaine="net view \\"+$server $pi=&{$chaine} i've tried $chaine="net view \\"+$server $pi=&($chaine) $pi too but nothing happens... $pi stays equal to $null; why ? if it is not so that i have to do, how could i execute a dos command and get the result into a PS variable ? btye Nico |
| | #2 (permalink) |
| Guest
Posts: n/a
| Re: dos command in powershell On 10 juil, 10:54, Nicopilami <n.chauss...@gmail.com> wrote: > Hi there, as suggested to me a few days ago, i'm trying to make a "net > use \\printerserver" into my ps1 scripts, but don't succeed; my > command line i try to use is > > $chaine="net view \\"+$server > $pi=&{$chaine} > > i've tried > > $chaine="net view \\"+$server > $pi=&($chaine) > $pi > > too but nothing happens... $pi stays equal to $null; why ? > > if it is not so that i have to do, how could i execute a dos command > and get the result into a PS variable ? > > btye > Nico ok, forget it, i've found : just type $chaine=net view \\$Serveur returns the result in $chaine. Thanks Nico |
| | #3 (permalink) |
| Guest
Posts: n/a
| Re: dos command in powershell Just a FYI. If you want to use variables in a string you use double quotes. This should so what you want. $chaine="net view \\$Serveur" invoke-expression $chaine "Nicopilami" <n.chaussard@gmail.com> wrote in message news:1184064576.672961.272640@q75g2000hsh.googlegroups.com... > On 10 juil, 10:54, Nicopilami <n.chauss...@gmail.com> wrote: >> Hi there, as suggested to me a few days ago, i'm trying to make a "net >> use \\printerserver" into my ps1 scripts, but don't succeed; my >> command line i try to use is >> >> $chaine="net view \\"+$server >> $pi=&{$chaine} >> >> i've tried >> >> $chaine="net view \\"+$server >> $pi=&($chaine) >> $pi >> >> too but nothing happens... $pi stays equal to $null; why ? >> >> if it is not so that i have to do, how could i execute a dos command >> and get the result into a PS variable ? >> >> btye >> Nico > > ok, forget it, i've found : just type > $chaine=net view \\$Serveur > returns the result in $chaine. > > > Thanks > Nico > |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Equivalent of powershell to vbscript command | IT STAFF | PowerShell | 1 | 1 Week Ago 05:08 AM |
| Powershell Command Prompt | eXtech | PowerShell | 4 | 12-08-2007 10:35 AM |
| How-to send CTRL+Z command in PowerShell | PaoloS | PowerShell | 3 | 11-27-2007 12:06 PM |
| Powershell.exe command-line syntax | EnigmaticSoul | PowerShell | 4 | 03-29-2007 08:40 PM |
| Info: Is there a known problem with x86 Powershell and command parsing on x64? | Brandon Shell | PowerShell | 0 | 03-13-2007 02:56 PM |