Posted By

jatubio on 02/23/15


Tagged

oop PowerShell


Versions (?)

Sample of declare a simple powershell class with a constructor


 / Published in: Windows PowerShell
 

Sample of declare a simple powershell class with a constructor thanks to Tome Tanasovski (http://powertoe.wordpress.com)

  1. #Sample of declare a simple powershell class with a constructor
  2. #thanks to Tome Tanasovski (http://powertoe.wordpress.com)
  3. function ExtendedWebClient ()
  4. {
  5. param(
  6. [Parameter(Mandatory=$true)]
  7. [String]$url,
  8. [Parameter(Mandatory=$false)]
  9. [string]$timeout
  10. )
  11.  
  12. $webclient = "" | Select url,timeout
  13. $webclient.url = $url
  14. $webclient.timeout = $timeout
  15.  
  16. $webclient;
  17. }
  18.  
  19. cls
  20. $extclient = ExtendedWebClient "www.myurl.com" 100
  21. $extclient

Report this snippet  

You need to login to post a comment.