From 5636f2b033242a04300aa97b71308e6bbab43e26 Mon Sep 17 00:00:00 2001 From: Paul Durivage Date: Thu, 19 Jun 2014 16:23:38 -0500 Subject: [PATCH] Move functions to top for correct scope --- windows/win_user.ps1 | 55 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/windows/win_user.ps1 b/windows/win_user.ps1 index dd8a7b4c284..6ce9d023681 100644 --- a/windows/win_user.ps1 +++ b/windows/win_user.ps1 @@ -19,6 +19,32 @@ # WANT_JSON # POWERSHELL_COMMON +######## +$adsi = [ADSI]"WinNT://$env:COMPUTERNAME" + +function Get-User($user) { + $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $user } + return +} + +function Create-User([string]$user, [string]$passwd) { + $user = $adsi.Create("User", $user) + $user.SetPassword($passwd) + $user.SetInfo() + $user + return +} + +function Update-Password($user, [string]$passwd) { + $user.SetPassword($passwd) + $user.SetInfo() +} + +function Delete-User($user) { + $adsi.delete("user", $user.Name.Value) +} +######## + $params = Parse-Args $args; $result = New-Object psobject @{ @@ -82,30 +108,9 @@ else { } } -$adsi = [ADSI]"WinNT://$env:COMPUTERNAME" - -function Get-User($user) { - $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $user } - return -} - -function Create-User([string]$user, [string]$passwd) { - $user = $adsi.Create("User", $user) - $user.SetPassword($passwd) - $user.SetInfo() - $user - return -} - -function Update-Password($user, [string]$passwd) { - $user.SetPassword($passwd) - $user.SetInfo() -} - -function Delete-User($user) { - $adsi.delete("user", $user.Name.Value) -} - -Set-Attr $result "user" $user_obj; # Soemthing goes here. +# Set-Attr $result "user" $user_obj +Set-Attr $result "user_name" $user_obj.Name +Set-Attr $result "user_fullname" $user_obj.FullName +Set-Attr $result "user_path" $user_obj.Path Exit-Json $result;