Guest User

Untitled

a guest
Feb 11th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <#
  2. .Description
  3. sets relevant tridion core service client settings
  4.  
  5. Write password by running
  6. Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File $CredentialFile
  7. #>
  8. [CmdletBinding()]
  9. Param (
  10. [Parameter(Mandatory=$false)]
  11. [String]$HostName='CMS.SAMPLE.DOMAIN',
  12.  
  13. [Parameter(Mandatory=$false)]
  14. [String]$User = 'DOMAIN\USER',
  15.  
  16. [Parameter(Mandatory=$false)]
  17. [String]$CredentialFile='C:\Some\Path\To\Credentials\samplePassword.txt'
  18. )
  19. Begin {
  20. Import-Module Tridion-CoreService -Verbose:$false
  21. }
  22.  
  23. Process {
  24. # Write password by running
  25. # read-host -assecurestring | convertfrom-securestring | out-file $credentialFile
  26. $credentialPassword = cat $credentialFile | convertto-securestring
  27.  
  28. $credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $user,$credentialPassword
  29.  
  30. Set-TridionCoreServiceSettings -HostName $HostName -ConnectionType Basic-SSL -CredentialType Basic -Credential $credential
  31. $client = Get-TridionCoreServiceClient
  32. $client.GetCurrentUser()
  33. }
Add Comment
Please, Sign In to add comment