Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Powershell equivilant to this?

308 views
Skip to first unread message

jmul...@idahopower.com

unread,
Sep 10, 2008, 5:12:56 PM9/10/08
to
is there an powershell equivelant to this that does not use the WMI
provider method?

set objShare=Nothing

set objShare= GetOBJect("WinNT://" & strSrv &"/lanmanserver")

WScript.echo "Server Name = " & strSrv

For Each share in objShare

WScript.echo "Examining " & share.name

wscript.echo "\\" & strSrv & "\" & share.name

tojo2000

unread,
Sep 10, 2008, 8:19:25 PM9/10/08
to

$server = [adsi]"WinNT://$strSrv/lanmanserver"

tojo2000

unread,
Sep 10, 2008, 8:21:41 PM9/10/08
to

Argh. I didn't mean to hit send. This seems to me like it should be
the equivalent, but maybe not because it doesn't give me a list of
shares. That does work if you want to use similar syntax to work on a
group.

Shay Levy [MVP]

unread,
Sep 11, 2008, 4:05:53 AM9/11/08
to
Try this:

$server = "serverName"
$shares = [ADSI]"WinNT://$server/lanmanserver"
$shares.psbase.children | select @{n="ShareName";e={$_.properties.name}},@{n="LocalPath";e={$_.properties.path}}

---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar


t> On Sep 10, 5:19 pm, tojo2000 <tojo2...@gmail.com> wrote:
t>

>> On Sep 10, 2:12 pm, jmull...@idahopower.com wrote:
>>
>>> is there an powershell equivelant to this that does not use the WMI
>>> provider method?
>>>
>>> set objShare=Nothing
>>>
>>> set objShare= GetOBJect("WinNT://" & strSrv &"/lanmanserver")
>>>
>>> WScript.echo "Server Name = " & strSrv
>>>
>>> For Each share in objShare
>>>
>>> WScript.echo "Examining " & share.name
>>>
>>> wscript.echo "\\" & strSrv & "\" & share.name
>>>
>> $server = [adsi]"WinNT://$strSrv/lanmanserver"
>>

t> Argh. I didn't mean to hit send. This seems to me like it should be
t> the equivalent, but maybe not because it doesn't give me a list of
t> shares. That does work if you want to use similar syntax to work on
t> a group.
t>


alexandair

unread,
Sep 11, 2008, 7:43:52 AM9/11/08
to
On Sep 11, 10:05 am, Shay Levy [MVP] <n...@addre.ss> wrote:
> Try this:
>
> $server = "serverName"
> $shares = [ADSI]"WinNT://$server/lanmanserver"
> $shares.psbase.children | select @{n="ShareName";e={$_.properties.name}},@{n="LocalPath";e={$_.properties.pa th}}
>
> ---
> Shay Levy
> Windows PowerShell MVPhttp://blogs.microsoft.co.il/blogs/ScriptFanatic
> PowerShell Toolbar:http://tinyurl.com/PSToolbar

Shay's solution works in PowerShell v2 CTP2. In v1 you have to
remove .properties

$server = "serverName"
$shares = [ADSI]"WinNT://$server/lanmanserver"
$shares.psbase.children | select

@{n="ShareName";e={$_.name}},@{n="LocalPath";e={$_.path}}

Calculated properties are used to remove {} around property values.
(You can try $shares.psbase.children | select name,path).

-aleksandar
http://powershellers.blogspot.com


Shay Levy [MVP]

unread,
Sep 11, 2008, 9:13:45 AM9/11/08
to
Alexandair, thanks for the correction. BTW, it works on CTP2 too :-)


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar


a> On Sep 11, 10:05 am, Shay Levy [MVP] <n...@addre.ss> wrote:
a>

>> Try this:
>>
>> $server = "serverName"
>> $shares = [ADSI]"WinNT://$server/lanmanserver"
>> $shares.psbase.children | select
>> @{n="ShareName";e={$_.properties.name}},@{n="LocalPath";e={$_.propert
>> ies.pa th}}
>> ---
>> Shay Levy
>> Windows PowerShell
>> MVPhttp://blogs.microsoft.co.il/blogs/ScriptFanatic
>> PowerShell Toolbar:http://tinyurl.com/PSToolbar

a> Shay's solution works in PowerShell v2 CTP2. In v1 you have to remove
a> .properties
a>
a> $server = "serverName"
a> $shares = [ADSI]"WinNT://$server/lanmanserver"
a> $shares.psbase.children | select
a> @{n="ShareName";e={$_.name}},@{n="LocalPath";e={$_.path}}
a> Calculated properties are used to remove {} around property values.
a> (You can try $shares.psbase.children | select name,path).
a>
a> -aleksandar
a> http://powershellers.blogspot.com


Flowering Weeds

unread,
Sep 13, 2008, 3:08:36 PM9/13/08
to

>
> is there an powershell equivelant to this
> that does not use the WMI
> provider method?
>

Mmm data parsing ADS
(WinNT or LDAP or IIS)?

Perhaps something usable
(local or remote) with any
Windows process?

LogParser.exe -h -i:ads

Input format: ADS (Active Directory)
Returns properties of Active Directory objects

Here using the Windows automation tool,
Windows PowerShell, automating the data
parsing tool, Log Parser.

$server = "."

LogParser.exe "SELECT
ObjectName AS ShareName,
PropertyValue AS FileSystemPath
FROM 'WinNT://$server/lanmanserver'
WHERE ObjectClass = 'FileShare'
AND
PropertyName = 'Path' " `
-i ads -stats off

If one has any troubles, just ask any Windows
automation tool user for help!

Have some fun - Log Parser it.


0 new messages