Advertisement
Guest User

Untitled

a guest
Sep 1st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. function Get-LogonToken {
  2.  
  3. [CmdletBinding()]
  4. param(
  5.  
  6. [Parameter(Position = 0, Mandatory = $true)]
  7. [ValidateNotNullOrEmpty()]
  8. [string] $ServerName,
  9.  
  10. [Parameter(Position = 1, Mandatory = $true)]
  11. [ValidateSet("secEnterprise", "secLDAP", "secWinAD")]
  12. [string] $Authentication,
  13.  
  14. [Parameter(Position = 2, Mandatory = $true)]
  15. [ValidateNotNullOrEmpty()]
  16. [string] $Username,
  17.  
  18. [Parameter(Position = 3, Mandatory = $true)]
  19. [ValidateNotNullOrEmpty()]
  20. [SecureString] $Password
  21.  
  22. )
  23.  
  24. Write-Verbose "ServerName: $ServerName"
  25. Write-Verbose "Authentication: $Authentication"
  26. Write-Verbose "Username: $Username"
  27. Write-Verbose "Password: $(ConvertFrom-SecureString $Password)"
  28.  
  29. ...
  30. }
  31.  
  32. [System.Management.Automation.Cmdlet(System.Management.Automation.VerbsCommon.Get, "LogonToken")]
  33. [OutputType(typeof(System.String))]
  34. public class GetLogonToken : System.Management.Automation.Cmdlet
  35. {
  36.  
  37. [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
  38. [ValidateNotNullOrEmpty]
  39. public string ServerName
  40. {
  41. get { return server; }
  42. set { server = value; }
  43. }
  44. private string server;
  45.  
  46. [System.Management.Automation.Parameter(Position = 1, Mandatory = true)]
  47. [ValidateSet("secEnterprise", "secLDAP", "secWinAD")]
  48. public string Authentication
  49. {
  50. get { return authentication; }
  51. set { authentication = value; }
  52. }
  53. private string authentication;
  54.  
  55. [System.Management.Automation.Parameter(Position = 2, Mandatory = true)]
  56. [ValidateNotNullOrEmpty]
  57. public string Username
  58. {
  59. get { return username; }
  60. set { username = value; }
  61. }
  62. private string username;
  63.  
  64. [System.Management.Automation.Parameter(Position = 3, Mandatory = true)]
  65. [ValidateNotNullOrEmpty]
  66. public SecureString Password
  67. {
  68. get { return password; }
  69. set { password = value; }
  70. }
  71. private SecureString password;
  72.  
  73. ...
  74.  
  75. }
  76.  
  77. PS> get-logontoken -verbose
  78.  
  79. cmdlet Get-LogonToken at command pipeline position 1
  80. Supply values for the following parameters:
  81. ServerName: server
  82. Authentication: sec<tab> (nothing generated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement