#Offboard Script Review
1 messages · Page 1 of 1 (latest)
I'd probably make it a module like a psm1 . I'd also probably wouldn't rely on $result being available in the child scopes and would pass it in directly.
Then there is adding get-help to it.
There is also things like psd1 too where you can set up module requirements. Additionally, I would probably have a check for $username to ensure someone wouldn't pass in domain\username
I'm also not a big fan of write-host and would switch to write-verbose 'verbose message' -verbose if you must have output for the user.
For errors I would use a write-error -ErrorRecord $_. Additionally, if you want to actually "throw" the errors in the nested functions you will need -ErrorAction Stop on your write-error or you'll need throw.
Just some rough cut immediate thoughts without any context of your user base or goals.