PowerShell - How to tweak this script to show URLs as well?

Hi there,

This PowerShell prints all users along with what groups they belong to. I need this to print the URL of the sites as well. Any suggestions?

Thanks.

$urlWeb = "http://dev"
Get-SPUser -Web $urlWeb -Limit All | select UserLogin, @{name="Explicit given roles";expression={$_.Roles}}, @{name="Roles given via groups";expression={$_.Groups | %{$_.Roles}}},Groups | format-Table -auto


  • Edited by frob 12 hours 17 minutes ago
February 23rd, 2015 6:50pm

The PowerShell command Get-SPUser gives information about a user of the site. It cannot be used to get the url of the sites. If your aim is to get the url of all sites in a given site, you can use following code:

Get-SPWeb "http://dev" |Select -ExpandProperty Webs | Select Url, Title

 
Free Windows Admin Tool Kit Click here and download it now
February 23rd, 2015 10:56pm

Frob,

you can use this way to print the supplied url 

$weburl = "http://yourweburl"
Get-SPUser -web $weburl | ?{$_.UserLogin -eq "NT AUTHORITY\authenticated users"} | %{$_.UserLogin + " - " + $weburl}


February 23rd, 2015 11:43pm

HI Frob,

Since you are using -Web attribute so the site url will always be the same as the url you have passed in the attribute parameter. If you want to print that url in output then this can be achived using below script

Get-SPUser -Web $urlWeb -Limit All | select UserLogin, @{name="Url";expression={$_.ParentWeb.Url}}, @{name="Explicit given roles";expression={$_.Roles}}, @{name="Roles given via groups";expression={$_.Groups | %{$_.Roles}}},Groups | format-Table -auto

Free Windows Admin Tool Kit Click here and download it now
February 24th, 2015 4:02am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics