Guest User

Untitled

a guest
Jun 18th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. function AS400_RDP{
  2. param (
  3. [Parameter(Mandatory=$True, Position=0)] [string]$server
  4. )
  5.  
  6. $server = Resolve-Path $server
  7. [xml]$ConfigFile = Get-Content -Path $server -Encoding UTF8
  8.  
  9. $Username1 = $ConfigFile.Settings.General.USERNAME
  10. $Password1 = $ConfigFile.Settings.General.PASSWORD
  11. $keyfile = $ConfigFile.Settings.General.KEYFILE
  12. $computerName1 = $ConfigFile.Settings.General.COMPUTERNAME
  13.  
  14. #Resolvemos las rutas
  15. $KeyFile = Resolve-Path $KeyFile
  16.  
  17. #Creamos Credenciales
  18. $Username = "$Username1"
  19. $Password = "$Password1"
  20. $computerName = "$computerName1"
  21.  
  22. #Creamos el objeto PSCredential
  23. $key = Get-Content $KeyFile
  24. $credential = New-Object -TypeName System.Management.Automation.PSCredential `
  25. -ArgumentList $Username, ($Password | ConvertTo-SecureString -Key $key)
  26.  
  27. #Iniciamos EL RDP
  28. Import-module .Connect-Mstsc.ps1
  29. Connect-Mstsc -ComputerName $computerName -Credential $credential -w 1024 -h 768
  30. }
  31.  
  32. AS400_RDP -server C:RutaarchivoXMLCON_DATOSCONEXION.xml
Add Comment
Please, Sign In to add comment