Set-ExecutionPolicy RemoteSigned次に、RSUBMITするSASコード
%macro adduser(name, passwd, fullname, desc);最後に、ユーザ追加のPS1を示します。
%let script=%bquote("C:\Documents and Settings\suzuki\desktop\foo1.ps1");
options noxwait xsync;
x "powershell.exe -file &script &name %quote(&passwd) %quote(&fullname) %quote(&desc)";
%if &sysrc=0 %then %do;
%put INFO: adduser success &name;
%end;
%else %do;
%put INFO: adduser error &name;
%end;
%mend;
options nomprint nosource;
%adduser(a, Sas4passworddayo!, %str(my name), %str(test desc));
%adduser(b, Sas4passworddayo!, %str(my name), %str(test desc));
%adduser(c, Sas4passworddayo!, %str(my name), %str(test desc));
#
# 変数宣言
#
$USER_NAME = $args[0]
$USER_PASSWORD = $args[1]
$USER_FULLNAME = $args[2]
$USER_DESCRIPTION = $args[3]
#
# ローカルユーザー作成
#
$computer = [ADSI]"WinNT://."
$user = $computer.Create("user", $USER_NAME)
$user.SetPassword($USER_PASSWORD)
$user.SetInfo()
$user.FullName = $USER_FULLNAME
$user.Description = $USER_DESCRIPTION
$user.UserFlags = 0x10000 #パスワードを無期限に設定
try {
$user.SetInfo()
}
catch {
exit 99
}
exit 0