Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

dos command in powershell

Closed Thread
 
Thread Tools Display Modes
Old 07-10-2007   #1 (permalink)
Nicopilami
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

 
Old 07-10-2007   #2 (permalink)
Nicopilami
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

 
Old 07-10-2007   #3 (permalink)
Brandon Shell
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
>


 
 
Closed Thread

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








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49