public ExecuteScript ( string script ) : Collection |
||
script | string | |
return | Collection |
public void ConnectSPOnlineTest2() { using (var scope = new PSTestScope(false)) { if (ConfigurationManager.AppSettings["SPOUserName"] != null && ConfigurationManager.AppSettings["SPOPassword"] != null) { var script = String.Format(@" [ValidateNotNullOrEmpty()] $userPassword = ""{1}"" $userPassword = ConvertTo-SecureString -String {1} -AsPlainText -Force $cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList {0}, $userPassword Connect-PnPOnline -Url {2} -Credentials $cred" , ConfigurationManager.AppSettings["SPOUserName"], ConfigurationManager.AppSettings["SPOPassword"], ConfigurationManager.AppSettings["SPODevSiteUrl"]); var results = scope.ExecuteScript(script); Assert.IsTrue(results.Count == 0); } else { Assert.Inconclusive("No credentials specified in app.config"); } } }
public void ConnectSPOnlineTest2() { using (var scope = new PSTestScope(false)) { if (ConfigurationManager.AppSettings["SPOUserName"] != null && ConfigurationManager.AppSettings["SPOPassword"] != null) { var script = String.Format(@" [ValidateNotNullOrEmpty()] $userPassword = ""{1}"" $userPassword = ConvertTo-SecureString -String {1} -AsPlainText -Force $cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList {0}, $userPassword Connect-SPOnline -Url {2} -Credentials $cred" , ConfigurationManager.AppSettings["SPOUserName"], ConfigurationManager.AppSettings["SPOPassword"], ConfigurationManager.AppSettings["SPODevSiteUrl"]); var results = scope.ExecuteScript(script); Assert.IsTrue(results.Count == 0); } else { Assert.Inconclusive("No credentials specified in app.config"); } } }