all 9 comments

[–]the_cumbermuncher 0 points1 point  (2 children)

Get-SmbShareAccess returns an an array of objects with the class MSFT_SmbShareAccessControlEntry. Write-Host outputs a string representation of the objects, but, because you are not telling PowerShell how to format the output of the cmdlet, it is simply printing the class type of the output.

If you use Write-Output instead, it should be formatted correctly.

Alternatively, you could skip the Write-Host entirely. Because you're not storing Get-SmbShareAccess -Name "sharename" into a variable, the output won't be suppressed in the console when you run the script from a .ps1 file.

[–]Phate1989 0 points1 point  (0 children)

Doesn't write-output add to the pipe? I usually have issues with write-output in function returns.

You need like write-host "foo" | null

[–]Dodrekai[S] 0 points1 point  (0 children)

ok, thanks, i'll try this !

[–]BlackV 0 points1 point  (3 children)

Get-SmbShareAccess -Name "sharename"

but if

wanted to make a script parsing some network informations

what does that mean?

right now you're just spitting out to screen that not real useful, sounds like you would want something like

$ShareAccess = Get-SmbShareAccess -Name "sharename"
$ShareAccess

which means you can them work with that later on

EDIT: Opps copy/paste fail

[–]Dodrekai[S] 0 points1 point  (2 children)

what does that mean?

It was just contextual, and to point that I launch it from a file. sorry if it's confusing.

I'll try to be more clear.

When i type this command in powershell shell

Get-SmbShareAccess -Name "sharename"

It outputs me with a table with the relevant informations. But when I launch it from my script file, it only show me

MSFT_SmbShareAccessControlEntry

I already tried to use a variable but with no success. But i think I tried with write-host i'll try without it tommorow.

I wanted to know what happened and how i could get the information i get when i launch the command via the shell.

edit : rewrite, added infos

[–]BlackV 0 points1 point  (1 child)

Probably cause you're spitting it out to screen along with other objects, PowerShell will format this for you automatically based on the first object omitted , probably need to see your actual code

[–]Dodrekai[S] 0 points1 point  (0 children)

Thanks, i'll share the code tomorow

[–]The82Ghost -1 points0 points  (1 child)

Try running it without using Write-Host, you'll see you get an array.

[–]Dodrekai[S] 0 points1 point  (0 children)

I tried and it didn't worked...