0

I am looking for some help here.

I have a need to find all infopath forms in a SharePoint online environment. I need to run through all site collections (alot of them) and write to csv file for review. I have noticed there is a powershell script here: infopath script how ever when I run it it keeps prompting me for login details for the next site collection. I have so many site collections is there anyway to stop this and keep running the script until the end automatically?. Also is there a way to output this to a csv file for review???

thanks!

1 Answer 1

0

This should work to convert your user login to pass through the script. Also, you can look at saving your password to a file if you want to have better security around your script.

$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)

or to file...

read-host -assecurestring | convertfrom-securestring | out-file C:\cred.txt

Once we have our password safely stored away, we can draw it back into our scripts..

$password = get-content C:\cred.txt | convertto-securestring

Then finally, we can create our credential object, which we pump into other cmdlets.

$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "myusername",$password

Then you can loop through each site collection. Wrap the code from your previous link into a function (Get-Forms) and loop through each site collection. You can opt to run this on a weekly schedule and exported the results to a SharePoint file library that held these kind of csv files.

$SiteCollections = Get-SPSite 'https://<site name>' | Get-SPWeb -Limit All | Select Title
foreach($Sitecollection in $SiteCollections){
     Get-Forms -SiteCollection $SiteCollection
}
1
  • Another way is to take a stab at the content types being used for each App. You can create and run a script to export this contents too. It would be helpful. May 23, 2019 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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