Page 1 of 1 1
Topic Options
#150542 - 2005-10-25 04:11 PM Change "Log On To" for all users
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Guys,

how can I get the following script to report / change "logon workstations" to "all workstations"?

Code:

CLS
BREAK ON
$DomainString='MyDomain'
$GroupString='Domain Users'
$GroupObj = GetObject('WinNT://' + $DomainString + '/' + $GroupString)
$logshare=@scriptdir
$logfile=$logshare+'\'+$DomainString+'_ChangeScriptLog.CSV'
del $logfile

For each $UserObj in $GroupObj.Members
?$UserObj.Name
$UserObj.LoginScript = 'StartLogon'
$UserObj.SetInfo
$logdata=$UserObj.Name+','+$UserObj.LoginScript+@CRLF
LOGGER($logfile,$logdata)
Next
?'--'
?'Script complete'
SLEEP 4

FUNCTION LOGGER($logfil,$logdat)
$result=0
$n=0
DO
$result=Open(1, $logfil, 5)
IF $result<>0
IF $n=0
;First wait
?'Please wait'
ELSE
;follow waits
'.'
ENDIF
SLEEP 3
ELSE
$result=WriteLine(1, $logdat)
$result=Close(1)
ENDIF
$n=$n+1
UNTIL $result=0 OR $n=5
ENDFUNCTION

_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#150543 - 2005-10-25 04:28 PM Re: Change "Log On To" for all users
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I think that you want the "LoginWorkstations" property.
Top
#150544 - 2005-10-25 04:40 PM Re: Change "Log On To" for all users
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Example for reporting purposes:
Code:
$oFSO=CreateObject("Scripting.FileSystemObject")
If @ERROR "ERROR creating FSO "+@ERROR+" "+@SERROR+@CRLF EndIf

$sDomain="MYDOMAIN"
$sGroup="SOME GROUP"

$oUsers=GetObject("WinNT://"+$sDomain+"/"+$sGroup+",group")
For Each $oUser in $oUsers.members
$oUser.Name+":"+@CRLF
For Each $sComputer in $oUser.LoginWorkstations
" " + $sComputer+@CRLF
Next
Next


Top
#150545 - 2005-10-25 08:15 PM Re: Change "Log On To" for all users
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Richard,

will try this tomorrow.

What's te code to allow a user to logon to ALL workstations?
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#150546 - 2005-10-26 10:20 AM Re: Change "Log On To" for all users
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Dunno specifically, but my guess would be to set the value to null.
Top
#150547 - 2005-10-26 01:18 PM Re: Change "Log On To" for all users
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
The reporting part works!

Now to get the code to change the property...


Will report back later.
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#150548 - 2005-10-26 01:40 PM Re: Change "Log On To" for all users
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
This is it:

Code:

$oUser.LoginWorkstations=""
$oUser.SetInfo

_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.057 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org