TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Windows Powershell

Powershell scripts not working with Vista powershell

Microsoft Windows Powershell

 
 
Thread Tools Display Modes
Unread 23-10-2007, 10:14 PM   #1
Ben
Guest
 
Posts: n/a
Powershell scripts not working with Vista powershell

Hi,

I am still in the process of learning Powershell and I am in the middle of
my transition from windows XP to Vista.. I was trying to run one of my
Powershell scripts in my Vista POSH client and it didn't return any
results... I then ran it on my XP powershell client and it worked fine?? i
am very confused are the versions of powershell that much different between
windows OS?

Here is the script...

$erroractionpreference = "silentlyContinue"
$root= new-object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
$domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
$search = new-object System.DirectoryServices.DirectorySearcher($domain )
$search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'


$computers = $search.findall()| foreach-object {
$comp = $_
$comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
if($comp.name -like "site1*") {write-output $comp.name}
elseif ($comp.name -like "site2*") {write-output $comp.name}
}
$computers.length
$result = foreach-object {
$service = Get-WmiObject -class Win32_Service -computername $computers |
where {$_.name -eq "clussvc"}
Write-output $service
}
$result.length
$result | sort | format-table -autosize systemName,Name,State,Status,startmode

Sponsored Links
 
Unread 23-10-2007, 10:14 PM   #2
Ben
Guest
 
Posts: n/a
RE: Powershell scripts not working with Vista powershell

Just to add to the previous post.... if i replace the computer search portion

$erroractionpreference = "silentlyContinue"
$root= new-object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
$domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
$search = new-object System.DirectoryServices.DirectorySearcher($domain )
$search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'


$computers = $search.findall()| foreach-object {
$comp = $_
$comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
if($comp.name -like "site1*") {write-output $comp.name}
elseif ($comp.name -like "site2*") {write-output $comp.name}
}

With :

$computers = "servername1","servername2","servername3","servern ame4"

then the following section works fine and displays the value of $result
correctly.

computers.length
$result = foreach-object {
$service = Get-WmiObject -class Win32_Service -computername $computers |
where {$_.name -eq "clussvc"}
Write-output $service
}
$result.length
$result | sort | format-table -autosize
systemName,Name,State,Status,startmode

am i doing something wrong??

any help is great appriciated!!

Thanks in advance
 
Unread 23-10-2007, 10:14 PM   #3
Kirk Munro
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

Hi Ben,

What happens if you comment out your $erroractionpreference =
"silentlyContinue" line in the script and then run it? Does Vista give you
any errors that were previously being hidden?

-
Kirk Munro
Poshoholic
http://poshoholic.com

"Ben" <Ben@discussions.microsoft.com> wrote in message
news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
> Just to add to the previous post.... if i replace the computer search
> portion
>
> $erroractionpreference = "silentlyContinue"
> $root= new-object
> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
> $search = new-object System.DirectoryServices.DirectorySearcher($domain )
> $search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>
>
> $computers = $search.findall()| foreach-object {
> $comp = $_
> $comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
> if($comp.name -like "site1*") {write-output $comp.name}
> elseif ($comp.name -like "site2*") {write-output $comp.name}
> }
>
> With :
>
> $computers = "servername1","servername2","servername3","servern ame4"
>
> then the following section works fine and displays the value of $result
> correctly.
>
> computers.length
> $result = foreach-object {
> $service = Get-WmiObject -class Win32_Service -computername $computers |
> where {$_.name -eq "clussvc"}
> Write-output $service
> }
> $result.length
> $result | sort | format-table -autosize
> systemName,Name,State,Status,startmode
>
> am i doing something wrong??
>
> any help is great appriciated!!
>
> Thanks in advance



 
Unread 23-10-2007, 10:15 PM   #4
Brandon Shell [MVP]
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

You may have more wrong, but one thing that stands out is your use of
foreach-object... that requires piped input.

$result = foreach-object {
$service = Get-WmiObject -class Win32_Service -computername $computers |
where {$_.name -eq "clussvc"}
Write-output $service
}

There are other things that are more a style issue, but this is the only
thing I see wrong.

"Ben" <Ben@discussions.microsoft.com> wrote in message
news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
> Just to add to the previous post.... if i replace the computer search
> portion
>
> $erroractionpreference = "silentlyContinue"
> $root= new-object
> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
> $search = new-object System.DirectoryServices.DirectorySearcher($domain )
> $search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>
>
> $computers = $search.findall()| foreach-object {
> $comp = $_
> $comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
> if($comp.name -like "site1*") {write-output $comp.name}
> elseif ($comp.name -like "site2*") {write-output $comp.name}
> }
>
> With :
>
> $computers = "servername1","servername2","servername3","servern ame4"
>
> then the following section works fine and displays the value of $result
> correctly.
>
> computers.length
> $result = foreach-object {
> $service = Get-WmiObject -class Win32_Service -computername $computers |
> where {$_.name -eq "clussvc"}
> Write-output $service
> }
> $result.length
> $result | sort | format-table -autosize
> systemName,Name,State,Status,startmode
>
> am i doing something wrong??
>
> any help is great appriciated!!
>
> Thanks in advance


 
Unread 23-10-2007, 10:15 PM   #5
Brandon Shell [MVP]
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

Can you try this?

$root = new-object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE")
$domain= $root.defaultNamingContext
$search = new-object
System.DirectoryServices.DirectorySearcher($domain ,'(&(objectCategory=Computer)(operatingSystem=*Ser ver*))')
$computers = $search.findall() |
where-Object{($comp.properties.dnshostname -match "site1") -or
($comp.properties.dnshostname -match "site2")}
$computers

"Ben" <Ben@discussions.microsoft.com> wrote in message
news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
> Just to add to the previous post.... if i replace the computer search
> portion
>
> $erroractionpreference = "silentlyContinue"
> $root= new-object
> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
> $search = new-object System.DirectoryServices.DirectorySearcher($domain )
> $search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>
>
> $computers = $search.findall()| foreach-object {
> $comp = $_
> $comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
> if($comp.name -like "site1*") {write-output $comp.name}
> elseif ($comp.name -like "site2*") {write-output $comp.name}
> }
>
> With :
>
> $computers = "servername1","servername2","servername3","servern ame4"
>
> then the following section works fine and displays the value of $result
> correctly.
>
> computers.length
> $result = foreach-object {
> $service = Get-WmiObject -class Win32_Service -computername $computers |
> where {$_.name -eq "clussvc"}
> Write-output $service
> }
> $result.length
> $result | sort | format-table -autosize
> systemName,Name,State,Status,startmode
>
> am i doing something wrong??
>
> any help is great appriciated!!
>
> Thanks in advance


 
Unread 23-10-2007, 10:15 PM   #6
Brandon Shell [MVP]
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

whoops... Try this instead

$root = new-object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE")
$domain= [ADSI]"LDAP://$($root.defaultNamingContext)"
$search = new-object
System.DirectoryServices.DirectorySearcher($domain ,'(&(objectCategory=Computer)(operatingSystem=*Ser ver*))')
$computers = $search.findall() |
where-Object{($_.properties.dnshostname -match "site1") -or
($_.properties.dnshostname -match "site2")}
$computers


"Brandon Shell [MVP]" <a_bshell@mk.hotmail.com> wrote in message
news:ev7yGwtCIHA.5228@TK2MSFTNGP05.phx.gbl...
> Can you try this?
>
> $root = new-object
> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE")
> $domain= $root.defaultNamingContext
> $search = new-object
> System.DirectoryServices.DirectorySearcher($domain ,'(&(objectCategory=Computer)(operatingSystem=*Ser ver*))')
> $computers = $search.findall() |
> where-Object{($comp.properties.dnshostname -match "site1") -or
> ($comp.properties.dnshostname -match "site2")}
> $computers
>
> "Ben" <Ben@discussions.microsoft.com> wrote in message
> news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
>> Just to add to the previous post.... if i replace the computer search
>> portion
>>
>> $erroractionpreference = "silentlyContinue"
>> $root= new-object
>> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
>> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
>> $search = new-object System.DirectoryServices.DirectorySearcher($domain )
>> $search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>>
>>
>> $computers = $search.findall()| foreach-object {
>> $comp = $_
>> $comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
>> if($comp.name -like "site1*") {write-output $comp.name}
>> elseif ($comp.name -like "site2*") {write-output $comp.name}
>> }
>>
>> With :
>>
>> $computers = "servername1","servername2","servername3","servern ame4"
>>
>> then the following section works fine and displays the value of $result
>> correctly.
>>
>> computers.length
>> $result = foreach-object {
>> $service = Get-WmiObject -class Win32_Service -computername $computers |
>> where {$_.name -eq "clussvc"}
>> Write-output $service
>> }
>> $result.length
>> $result | sort | format-table -autosize
>> systemName,Name,State,Status,startmode
>>
>> am i doing something wrong??
>>
>> any help is great appriciated!!
>>
>> Thanks in advance

>


 
Unread 23-10-2007, 10:16 PM   #7
Kirk Munro
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

Hi Brandon,

Actually I was going to post that very same thing because it jumped out at
me too, but then I tested it and it works just fine (on my XP laptop at
least). So while it isn't very intuitive and the use of ForEach-Object is
actually altogether unnecessary for that section of the script, I don't
think it is "wrong". It's just...um...creatively obscure.

-
Kirk Munro
Poshoholic
http://poshoholic.com

"Brandon Shell [MVP]" <a_bshell@mk.hotmail.com> wrote in message
news:eat$3ptCIHA.5160@TK2MSFTNGP05.phx.gbl...
> You may have more wrong, but one thing that stands out is your use of
> foreach-object... that requires piped input.
>
> $result = foreach-object {
> $service = Get-WmiObject -class Win32_Service -computername $computers |
> where {$_.name -eq "clussvc"}
> Write-output $service
> }
>
> There are other things that are more a style issue, but this is the only
> thing I see wrong.
>
> "Ben" <Ben@discussions.microsoft.com> wrote in message
> news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
>> Just to add to the previous post.... if i replace the computer search
>> portion
>>
>> $erroractionpreference = "silentlyContinue"
>> $root= new-object
>> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
>> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
>> $search = new-object System.DirectoryServices.DirectorySearcher($domain )
>> $search.filter = '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>>
>>
>> $computers = $search.findall()| foreach-object {
>> $comp = $_
>> $comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
>> if($comp.name -like "site1*") {write-output $comp.name}
>> elseif ($comp.name -like "site2*") {write-output $comp.name}
>> }
>>
>> With :
>>
>> $computers = "servername1","servername2","servername3","servern ame4"
>>
>> then the following section works fine and displays the value of $result
>> correctly.
>>
>> computers.length
>> $result = foreach-object {
>> $service = Get-WmiObject -class Win32_Service -computername $computers |
>> where {$_.name -eq "clussvc"}
>> Write-output $service
>> }
>> $result.length
>> $result | sort | format-table -autosize
>> systemName,Name,State,Status,startmode
>>
>> am i doing something wrong??
>>
>> any help is great appriciated!!
>>
>> Thanks in advance

>



 
Unread 23-10-2007, 10:16 PM   #8
Brandon Shell [MVP]
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

I apologize... I didn't mean you could use Foreach-Object that way.. I meant
you have to provide some objects to foreach through.

One would need $computers at the end of the foreach-object
foreach-object -process {echo $_} -input @(1..10)

Either way... I agree with you.. remove the $erroractionpreference

"Kirk Munro" <sorry@nospam.org> wrote in message
news:e0M29wuCIHA.5044@TK2MSFTNGP03.phx.gbl...
> Hi Brandon,
>
> Actually I was going to post that very same thing because it jumped out at
> me too, but then I tested it and it works just fine (on my XP laptop at
> least). So while it isn't very intuitive and the use of ForEach-Object is
> actually altogether unnecessary for that section of the script, I don't
> think it is "wrong". It's just...um...creatively obscure.
>
> -
> Kirk Munro
> Poshoholic
> http://poshoholic.com
>
> "Brandon Shell [MVP]" <a_bshell@mk.hotmail.com> wrote in message
> news:eat$3ptCIHA.5160@TK2MSFTNGP05.phx.gbl...
>> You may have more wrong, but one thing that stands out is your use of
>> foreach-object... that requires piped input.
>>
>> $result = foreach-object {
>> $service = Get-WmiObject -class Win32_Service -computername $computers |
>> where {$_.name -eq "clussvc"}
>> Write-output $service
>> }
>>
>> There are other things that are more a style issue, but this is the only
>> thing I see wrong.
>>
>> "Ben" <Ben@discussions.microsoft.com> wrote in message
>> news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
>>> Just to add to the previous post.... if i replace the computer search
>>> portion
>>>
>>> $erroractionpreference = "silentlyContinue"
>>> $root= new-object
>>> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
>>> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
>>> $search = new-object System.DirectoryServices.DirectorySearcher($domain )
>>> $search.filter =
>>> '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>>>
>>>
>>> $computers = $search.findall()| foreach-object {
>>> $comp = $_
>>> $comp | add-member noteproperty "Name" $comp.properties["name"].item(0)
>>> if($comp.name -like "site1*") {write-output $comp.name}
>>> elseif ($comp.name -like "site2*") {write-output $comp.name}
>>> }
>>>
>>> With :
>>>
>>> $computers = "servername1","servername2","servername3","servern ame4"
>>>
>>> then the following section works fine and displays the value of $result
>>> correctly.
>>>
>>> computers.length
>>> $result = foreach-object {
>>> $service = Get-WmiObject -class Win32_Service -computername $computers
>>> |
>>> where {$_.name -eq "clussvc"}
>>> Write-output $service
>>> }
>>> $result.length
>>> $result | sort | format-table -autosize
>>> systemName,Name,State,Status,startmode
>>>
>>> am i doing something wrong??
>>>
>>> any help is great appriciated!!
>>>
>>> Thanks in advance

>>

>
>


 
Unread 23-10-2007, 10:22 PM   #9
Brandon Shell [MVP]
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

Btw... I think the reason his orginal Foreach-object worked is because Get-WMIObject
takes an array for computername

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject

B> I apologize... I didn't mean you could use Foreach-Object that way..
B> I meant you have to provide some objects to foreach through.
B>
B> One would need $computers at the end of the foreach-object
B> foreach-object -process {echo $_} -input @(1..10)
B>
B> Either way... I agree with you.. remove the $erroractionpreference
B>
B> "Kirk Munro" <sorry@nospam.org> wrote in message
B> news:e0M29wuCIHA.5044@TK2MSFTNGP03.phx.gbl...
B>
>> Hi Brandon,
>>
>> Actually I was going to post that very same thing because it jumped
>> out at me too, but then I tested it and it works just fine (on my XP
>> laptop at least). So while it isn't very intuitive and the use of
>> ForEach-Object is actually altogether unnecessary for that section of
>> the script, I don't think it is "wrong". It's just...um...creatively
>> obscure.
>>
>> -
>> Kirk Munro
>> Poshoholic
>> http://poshoholic.com
>> "Brandon Shell [MVP]" <a_bshell@mk.hotmail.com> wrote in message
>> news:eat$3ptCIHA.5160@TK2MSFTNGP05.phx.gbl...
>>
>>> You may have more wrong, but one thing that stands out is your use
>>> of foreach-object... that requires piped input.
>>>
>>> $result = foreach-object {
>>> $service = Get-WmiObject -class Win32_Service -computername
>>> $computers |
>>> where {$_.name -eq "clussvc"}
>>> Write-output $service
>>> }
>>> There are other things that are more a style issue, but this is the
>>> only thing I see wrong.
>>>
>>> "Ben" <Ben@discussions.microsoft.com> wrote in message
>>> news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
>>>
>>>> Just to add to the previous post.... if i replace the computer
>>>> search portion
>>>>
>>>> $erroractionpreference = "silentlyContinue"
>>>> $root= new-object
>>>> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
>>>> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
>>>> $search = new-object
>>>> System.DirectoryServices.DirectorySearcher($domain )
>>>> $search.filter =
>>>> '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>>>> $computers = $search.findall()| foreach-object {
>>>> $comp = $_
>>>> $comp | add-member noteproperty "Name"
>>>> $comp.properties["name"].item(0)
>>>> if($comp.name -like "site1*") {write-output $comp.name}
>>>> elseif ($comp.name -like "site2*") {write-output $comp.name}
>>>> }
>>>> With :
>>>>
>>>> $computers =
>>>> "servername1","servername2","servername3","servern ame4"
>>>>
>>>> then the following section works fine and displays the value of
>>>> $result correctly.
>>>>
>>>> computers.length
>>>> $result = foreach-object {
>>>> $service = Get-WmiObject -class Win32_Service -computername
>>>> $computers
>>>> |
>>>> where {$_.name -eq "clussvc"}
>>>> Write-output $service
>>>> }
>>>> $result.length
>>>> $result | sort | format-table -autosize
>>>> systemName,Name,State,Status,startmode
>>>> am i doing something wrong??
>>>>
>>>> any help is great appriciated!!
>>>>
>>>> Thanks in advance
>>>>



 
Unread 23-10-2007, 10:23 PM   #10
Kirk Munro
Guest
 
Posts: n/a
Re: Powershell scripts not working with Vista powershell

Sponsored Links
I'm not so sure. You can execute this one-liner in PowerShell just fine:

$wmiServices = ForEach-Object { Get-Service wmi* }

And after the execution is done, $wmiServices will contain all services that
start with wmi. It surprised me that this would work at all. I wonder if
the PowerShell interpreter is recognizing that ForEach-Object doesn't have
any input and therefore is simply executing the contents. At any rate, the
ForEach-Object cmdlet is not necessary at all in cases like this and can be
removed. My only point was that according to PowerShell it doesn't seem to
be "wrong".

-
Kirk Munro
Poshoholic
http://poshoholic.com

"Brandon Shell [MVP]" <a_bshell.mask*************> wrote in message
news:29d4f646192c8c9d939ea074264@nn.bloomberg.com. ..
> Btw... I think the reason his orginal Foreach-object worked is because
> Get-WMIObject takes an array for computername
>
> Brandon Shell
> ---------------
> Blog: http://www.bsonposh.com/
> PSH Scripts Project: www.codeplex.com/psobject
>
> B> I apologize... I didn't mean you could use Foreach-Object that way..
> B> I meant you have to provide some objects to foreach through.
> B> B> One would need $computers at the end of the foreach-object
> B> foreach-object -process {echo $_} -input @(1..10)
> B> B> Either way... I agree with you.. remove the $erroractionpreference
> B> B> "Kirk Munro" <sorry@nospam.org> wrote in message
> B> news:e0M29wuCIHA.5044@TK2MSFTNGP03.phx.gbl...
> B>
>>> Hi Brandon,
>>>
>>> Actually I was going to post that very same thing because it jumped
>>> out at me too, but then I tested it and it works just fine (on my XP
>>> laptop at least). So while it isn't very intuitive and the use of
>>> ForEach-Object is actually altogether unnecessary for that section of
>>> the script, I don't think it is "wrong". It's just...um...creatively
>>> obscure.
>>>
>>> -
>>> Kirk Munro
>>> Poshoholic
>>> http://poshoholic.com
>>> "Brandon Shell [MVP]" <a_bshell@mk.hotmail.com> wrote in message
>>> news:eat$3ptCIHA.5160@TK2MSFTNGP05.phx.gbl...
>>>
>>>> You may have more wrong, but one thing that stands out is your use
>>>> of foreach-object... that requires piped input.
>>>>
>>>> $result = foreach-object {
>>>> $service = Get-WmiObject -class Win32_Service -computername
>>>> $computers |
>>>> where {$_.name -eq "clussvc"}
>>>> Write-output $service
>>>> }
>>>> There are other things that are more a style issue, but this is the
>>>> only thing I see wrong.
>>>>
>>>> "Ben" <Ben@discussions.microsoft.com> wrote in message
>>>> news:094A48E5-D2EB-4088-9685-73A8411163F8@microsoft.com...
>>>>
>>>>> Just to add to the previous post.... if i replace the computer
>>>>> search portion
>>>>>
>>>>> $erroractionpreference = "silentlyContinue"
>>>>> $root= new-object
>>>>> System.DirectoryServices.DirectoryEntry("LDAP://RootDSE");
>>>>> $domain=[adsi]("LDAP://" + $root.Get("defaultNamingContext"));
>>>>> $search = new-object
>>>>> System.DirectoryServices.DirectorySearcher($domain )
>>>>> $search.filter =
>>>>> '(&(objectCategory=Computer)(operatingSystem=*Serv er*))'
>>>>> $computers = $search.findall()| foreach-object {
>>>>> $comp = $_
>>>>> $comp | add-member noteproperty "Name"
>>>>> $comp.properties["name"].item(0)
>>>>> if($comp.name -like "site1*") {write-output $comp.name}
>>>>> elseif ($comp.name -like "site2*") {write-output $comp.name}
>>>>> }
>>>>> With :
>>>>>
>>>>> $computers =
>>>>> "servername1","servername2","servername3","servern ame4"
>>>>>
>>>>> then the following section works fine and displays the value of
>>>>> $result correctly.
>>>>>
>>>>> computers.length
>>>>> $result = foreach-object {
>>>>> $service = Get-WmiObject -class Win32_Service -computername
>>>>> $computers
>>>>> |
>>>>> where {$_.name -eq "clussvc"}
>>>>> Write-output $service
>>>>> }
>>>>> $result.length
>>>>> $result | sort | format-table -autosize
>>>>> systemName,Name,State,Status,startmode
>>>>> am i doing something wrong??
>>>>>
>>>>> any help is great appriciated!!
>>>>>
>>>>> Thanks in advance
>>>>>

>
>




Sponsored Links
 
 

Thread Tools
Display Modes



< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 10:04 PM.


vBulletin, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 2005-2016, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional