public System.Management.Automation.PSCredential GetCredential() { var userName = string.Format(@"{0}\{1}", name, Administrator.UserName); var securePassword = new System.Security.SecureString(); securePassword.AppendString(Administrator.Password); var cred = new System.Management.Automation.PSCredential(userName, securePassword); return(cred); }