AftabHussain

Connect to WebsitePanel, SolidCP using PowerShell

Apr 28th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Connect-WSP
  2. {
  3.     param(
  4.         [parameter(Mandatory=$true)]
  5.         [string]$Username,
  6.         [parameter(Mandatory=$true)]
  7.         [string]$Password,
  8.         [parameter(Mandatory=$true)]
  9.         [string]$Server,
  10.         [parameter(Mandatory=$false)]
  11.         [int]$Port = '9002',
  12.         [parameter(Mandatory=$true)]
  13.         [string]$Endpoint
  14.     )
  15.  
  16.     $Secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force
  17.     $Credential = New-Object System.Management.Automation.PSCredential($Username, $Secpasswd)
  18.  
  19.     $Proxy = New-WebServiceProxy -Uri "http://$Server`:$Port/$Endpoint" -Credential $Credential
  20.  
  21.     return $Proxy
  22. }
  23.  
  24. $Wsp = Connect-WSP -Username serveradmin -Password MyS3cureP@ssword -Server myServer.com -Endpoint esUsers.asmx
  25.  
  26. $Wsp.GetUserById(2)
Advertisement
Add Comment
Please, Sign In to add comment