create connect-server type powershell cmdlet
we use product called papercut handle printing students , staff, , i'm wanting create powershell module contains cmdlets map functions exposed api. these cmdlets require server connection in order work, object contains name of server connect to, port it's listening on, , authentication token string.
i'd have this
connect-pcutserver -server pcut -port 9191 -authtoken blahblahblah
once connected subsequent cmdlets add-printer, rename-user , on able take advantage of connection. if writing in powershell instead of c# store $global:variable or similar. functions check see if $global:variable existed, if things, if not prompt user run connect-server cmdlet.
i can create cmdlet called connect-server, accepts 3 params, proper way of doing return $global:object (is possible), or there a better way handle this?
thanks,
jeffrey s. patton jeffrey s. patton systems specialist, enterprise systems university of kansas 1001 sunnyside ave. lawrence, ks. 66045 (785) 864-0242 | http://patton-tech.com
well, silly over-thinking problem completely. wound doing following
public class globals { public static string authtoken; public static string computername; public static int port; }
in connect cmdlet, set values provided on cmdline. remaining cmdlets test if 1 of props null, if kick out message run connect cmdlet.
jeffrey s. patton jeffrey s. patton systems specialist, enterprise systems university of kansas 1001 sunnyside ave. lawrence, ks. 66045 (785) 864-0242 | http://patton-tech.com
Windows Server > Windows PowerShell
Comments
Post a Comment