1

Is it possible to run multiple ps script and write the outcome to a file. for example, below. I can add each line in () | out-file -append test.txt -width 120. The problem is I dont want title and under score. Just want the 1 line result.

Get-SPSite F969095A-2AAF-4CEC-A8C8-086606F58959 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "4C28F38A-CB0E-45B0-AB67-48D841D3897A"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7EB84F0A-68AD-43F4-A4CD-0C08DB955885 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "00000000-0000-0000-0000-000000000000"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7EB84F0A-68AD-43F4-A4CD-0C08DB955885 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "74FF7F0A-0D3D-47F1-8435-1F8597CF14D9"} | ft Title, ParentWebURL, RootFolder
Get-SPSite DC650388-F3F5-4F41-BA3D-121F3586D8B7 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "718A92B3-511D-43A6-9C5D-27CDAD1476E3"} | ft Title, ParentWebURL, RootFolder
Get-SPSite DC650388-F3F5-4F41-BA3D-121F3586D8B7 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "F968C3F3-E6A3-4CE8-99E8-A8B5F984AE9D"} | ft Title, ParentWebURL, RootFolder
Get-SPSite DC650388-F3F5-4F41-BA3D-121F3586D8B7 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "EAF72D1D-89B7-4F93-99EC-B2D8C3777369"} | ft Title, ParentWebURL, RootFolder
Get-SPSite DC650388-F3F5-4F41-BA3D-121F3586D8B7 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "A1972377-D1C3-4B52-8E3D-F84CD87D2ED6"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "00000000-0000-0000-0000-000000000000"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "D4951A83-2EDA-4556-BA3E-17A6E6674073"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "514304E5-11DD-4478-9F7D-280CF1A271F9"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "0D9CB0AC-5926-4F01-8B55-3DFAB3658D8B"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "A6162406-4858-4C11-A917-8F663CA635FD"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "8F2CB028-847B-4AE7-919B-C8CEFCFDFB3F"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 7C473090-F368-4D14-96B7-1EBA6ED064B4 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "127A6FC4-0A56-4CE4-B437-E7810B5A0CD5"} | ft Title, ParentWebURL, RootFolder
Get-SPSite 1B33B7AB-4FDF-4E44-938D-3CDBF74DCC4E | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "789C6C33-5EAE-4DA7-9C28-4F965CD6C73B"} | ft Title, ParentWebURL, RootFolder
2

You can try the below code (not fancy but its works, may a dev guy can help u with better code).

$d = Get-SPSite F969095A-2AAF-4CEC-A8C8-086606F58959 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "4C28F38A-CB0E-45B0-AB67-48D841D3897A"} |Select-Object Title, ParentWebURL, RootFolder
$d | Export-CSV -Append  "C:\Listpout.csv"
$d = Get-SPSite 7EB84F0A-68AD-43F4-A4CD-0C08DB955885 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "00000000-0000-0000-0000-000000000000"} | Select-Object Title, ParentWebURL, RootFolder
$d | Export-CSV -Append  "C:\Listpout.csv"
$d = Get-SPSite 7EB84F0A-68AD-43F4-A4CD-0C08DB955885 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "74FF7F0A-0D3D-47F1-8435-1F8597CF14D9"} | Select-Object Title, ParentWebURL, RootFolder
$d | Export-CSV -Append  "C:\Listpout.csv"
$d = Get-SPSite DC650388-F3F5-4F41-BA3D-121F3586D8B7 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "718A92B3-511D-43A6-9C5D-27CDAD1476E3"} | Select-Object Title, ParentWebURL, RootFolder
$d | Export-CSV -Append  "C:\Listpout.csv"
$d = Get-SPSite DC650388-F3F5-4F41-BA3D-121F3586D8B7 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "F968C3F3-E6A3-4CE8-99E8-A8B5F984AE9D"} |Select-Object Title, ParentWebURL, RootFolder
$d | Export-CSV -Append  "C:\Listpout.csv"

You can save the scipt into the one PS1 file and run that file.

2
  • Thanks Waqas. It worked. Wish there was a way to not to export title and underline from each one of this. I guess i can import this in excel and clean it up. Thanks again. Nov 9 '17 at 1:38
  • @BettySmith Please don't forget to mark the answer as accepted in case it helped you to solve your issue, Thanks! Nov 9 '17 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.