Home All Groups Group Topic Archive Search About


Author
10 May 2005 3:15 PM
arell12
I have a very basic script that will show me when a user last changed
their password.  I need some help modifying it so it will ask me the
user and OU.

Here is the existing script

set objUser =
GetObject("LDAP://CN=damian,OU=admins,OU=theshack,DC=DC1,DC=theshack,DC=com")

dtmValue = objUser.PasswordLastChanged
WScript.Echo "Password last changed: " & dtmValue

but instead I want to have the script ask for the username, and OU's
(iff possible) instead of me having to edit the script file.

Thanks

Author
10 May 2005 6:39 PM
Jim Vierra
If you use csript use

Wscript.Echo "Enter username:"
Dim pw 'As SCRIPTPWLib.Password
Set pw = CreateObject("ScriptPW.Password") ' Hides input on screen.
str1  = pw.GetPassword()

or with Dialog
str1 = InputBox("Enter Username","MyTitle")


--
Jim Vierra

Show quote
"arell12" <arel***@hotmail.com> wrote in message news:1115738142.762955.7910@o13g2000cwo.googlegroups.com...
>I have a very basic script that will show me when a user last changed
> their password.  I need some help modifying it so it will ask me the
> user and OU.
>
> Here is the existing script
>
> set objUser =
> GetObject("LDAP://CN=damian,OU=admins,OU=theshack,DC=DC1,DC=theshack,DC=com")
>
> dtmValue = objUser.PasswordLastChanged
> WScript.Echo "Password last changed: " & dtmValue
>
> but instead I want to have the script ask for the username, and OU's
> (iff possible) instead of me having to edit the script file.
>
> Thanks
>
Author
13 Jun 2005 8:34 PM
eli
Speaking of 'ScriptPW.dll', I was using it with success, but then it just
stopped working.  Any ideas on why?
I used the lines directly from the script center:
'* User Authentication Section
Wscript.StdOut.Write "Please enter the user name: "
strUser = WScript.StdIn.ReadLine

Set objPassword = CreateObject("ScriptPW.Password")
Wscript.StdOut.Write "Please enter your password:"
strPassword = objPassword.GetPassword()
Wscript.Echo

'* Trouble shooting code here
If strPassword = "" Then
    Wscript.Echo " No Password"
    Wscript.Quit
End If

After entering the username and pressing "Enter", the program skips right by
the ScriptPW and echos "No password".

Thanks in advance.
Eli
Show quote
"Jim Vierra" wrote:

> If you use csript use
>
> Wscript.Echo "Enter username:"
> Dim pw 'As SCRIPTPWLib.Password
> Set pw = CreateObject("ScriptPW.Password") ' Hides input on screen.
> str1  = pw.GetPassword()
>
> or with Dialog
> str1 = InputBox("Enter Username","MyTitle")
>
>
> --
> Jim Vierra
>
> "arell12" <arel***@hotmail.com> wrote in message news:1115738142.762955.7910@o13g2000cwo.googlegroups.com...
> >I have a very basic script that will show me when a user last changed
> > their password.  I need some help modifying it so it will ask me the
> > user and OU.
> >
> > Here is the existing script
> >
> > set objUser =
> > GetObject("LDAP://CN=damian,OU=admins,OU=theshack,DC=DC1,DC=theshack,DC=com")
> >
> > dtmValue = objUser.PasswordLastChanged
> > WScript.Echo "Password last changed: " & dtmValue
> >
> > but instead I want to have the script ask for the username, and OU's
> > (iff possible) instead of me having to edit the script file.
> >
> > Thanks
> >
Author
14 Jun 2005 3:51 PM
Torgeir Bakken (MVP)
eli wrote:

Show quote
> Speaking of 'ScriptPW.dll', I was using it with success, but then it just
> stopped working.  Any ideas on why?
> I used the lines directly from the script center:
> '* User Authentication Section
> Wscript.StdOut.Write "Please enter the user name: "
> strUser = WScript.StdIn.ReadLine
>
> Set objPassword = CreateObject("ScriptPW.Password")
> Wscript.StdOut.Write "Please enter your password:"
> strPassword = objPassword.GetPassword()
> Wscript.Echo
>
> '* Trouble shooting code here
> If strPassword = "" Then
>     Wscript.Echo " No Password"
>     Wscript.Quit
> End If
>
> After entering the username and pressing "Enter", the program skips right by
> the ScriptPW and echos "No password".
>
> Thanks in advance.
Hi,

See it this command helps (run it from Start/Run):

regsvr32.exe %windir%\System32\scriptpw.dll


If not, reinstall WSH and see if that helps.

WSH 5.6 installation files can be downloaded from here:

http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
Author
14 Jun 2005 4:09 PM
eli
Thanks for your response. Registering the dll was my first step in trouble
shooting.
I did determine the cause; my faulty script.
I had "Option Explicit" at the very beginning of the script.
I commented this out, and it works as it should.  I will try to better
understand scripting from this lesson!

Show quote
"Torgeir Bakken (MVP)" wrote:

> eli wrote:
>
> > Speaking of 'ScriptPW.dll', I was using it with success, but then it just
> > stopped working.  Any ideas on why?
> > I used the lines directly from the script center:
> > '* User Authentication Section
> > Wscript.StdOut.Write "Please enter the user name: "
> > strUser = WScript.StdIn.ReadLine
> >
> > Set objPassword = CreateObject("ScriptPW.Password")
> > Wscript.StdOut.Write "Please enter your password:"
> > strPassword = objPassword.GetPassword()
> > Wscript.Echo
> >
> > '* Trouble shooting code here
> > If strPassword = "" Then
> >     Wscript.Echo " No Password"
> >     Wscript.Quit
> > End If
> >
> > After entering the username and pressing "Enter", the program skips right by
> > the ScriptPW and echos "No password".
> >
> > Thanks in advance.
> Hi,
>
> See it this command helps (run it from Start/Run):
>
> regsvr32.exe %windir%\System32\scriptpw.dll
>
>
> If not, reinstall WSH and see if that helps.
>
> WSH 5.6 installation files can be downloaded from here:
>
> http://msdn.microsoft.com/downloads/list/webdev.asp
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>
Author
14 Jun 2005 4:22 PM
Ramon Jiménez
In any case Option Explicit is a good practice in coding, in general...

--
Saludos
Ramon
Show quote
"eli" <e**@discussions.microsoft.com> wrote in message
news:49E79372-8D1B-47DF-9FE5-0BB568C00346@microsoft.com...
> Thanks for your response. Registering the dll was my first step in trouble
> shooting.
> I did determine the cause; my faulty script.
> I had "Option Explicit" at the very beginning of the script.
> I commented this out, and it works as it should.  I will try to better
> understand scripting from this lesson!
>
> "Torgeir Bakken (MVP)" wrote:
>
> > eli wrote:
> >
> > > Speaking of 'ScriptPW.dll', I was using it with success, but then it
just
> > > stopped working.  Any ideas on why?
> > > I used the lines directly from the script center:
> > > '* User Authentication Section
> > > Wscript.StdOut.Write "Please enter the user name: "
> > > strUser = WScript.StdIn.ReadLine
> > >
> > > Set objPassword = CreateObject("ScriptPW.Password")
> > > Wscript.StdOut.Write "Please enter your password:"
> > > strPassword = objPassword.GetPassword()
> > > Wscript.Echo
> > >
> > > '* Trouble shooting code here
> > > If strPassword = "" Then
> > >     Wscript.Echo " No Password"
> > >     Wscript.Quit
> > > End If
> > >
> > > After entering the username and pressing "Enter", the program skips
right by
> > > the ScriptPW and echos "No password".
> > >
> > > Thanks in advance.
> > Hi,
> >
> > See it this command helps (run it from Start/Run):
> >
> > regsvr32.exe %windir%\System32\scriptpw.dll
> >
> >
> > If not, reinstall WSH and see if that helps.
> >
> > WSH 5.6 installation files can be downloaded from here:
> >
> > http://msdn.microsoft.com/downloads/list/webdev.asp
> >
> >
> > --
> > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> > Administration scripting examples and an ONLINE version of
> > the 1328 page Scripting Guide:
> > http://www.microsoft.com/technet/scriptcenter/default.mspx
> >
Author
14 Jun 2005 4:26 PM
Torgeir Bakken (MVP)
eli wrote:

> Thanks for your response. Registering the dll was my first step in trouble
> shooting.
> I did determine the cause; my faulty script.
> I had "Option Explicit" at the very beginning of the script.
> I commented this out, and it works as it should.  I will try to better
> understand scripting from this lesson!
Hi,

The script works fine with Option Explicit (run the script below).

But I guess you have an "On Error Resume Next" in your script,
and you had failed to "Dim" all the variables, but the error was
suppressed by the "On Error Resume Next".

It is a good thing to use "Option Explicit", and you should not use
"On Error Resume Next" unless it is very necessary, and then turn
it off again with "On Error Goto 0" right below where you needed
"On Error Resume Next".


'--------------------8<----------------------
Option Explicit

Dim strUser, objPassword, strPassword

'* User Authentication Section
Wscript.StdOut.Write "Please enter the user name: "
strUser = WScript.StdIn.ReadLine

Set objPassword = CreateObject("ScriptPW.Password")
Wscript.StdOut.Write "Please enter your password:"
strPassword = objPassword.GetPassword()
Wscript.Echo

'* Trouble shooting code here
If strPassword = "" Then
     Wscript.Echo " No Password"
     Wscript.Quit
End If

Wscript.Echo strUser
Wscript.Echo strPassword

'--------------------8<----------------------



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
Author
13 May 2005 6:00 PM
Nancy
Hi,

This should work, we use it here all the time:

Set WSHShell = WScript.CreateObject("WScript.Shell")

UserName = InputBox("Enter Name of User","Last Password Reset","ie John Doe")
OrgUnit = InputBox("Enter Organizational Unit for " & UserName, "Last
Password Reset","ie NewYork")

If UserName <> "" Then

    Set objUser =
GetObject("LDAP://CN="&UserName&",OU="&OrgUnit&",DC=yourdomain,DC=com")

    dtmValue = objUser.PasswordLastChanged
    WScript.echo "User's password was last changed on " & dtmValue
End If

Nancy

Show quote
"arell12" wrote:

> I have a very basic script that will show me when a user last changed
> their password.  I need some help modifying it so it will ask me the
> user and OU.
>
> Here is the existing script
>
> set objUser =
> GetObject("LDAP://CN=damian,OU=admins,OU=theshack,DC=DC1,DC=theshack,DC=com")
>
> dtmValue = objUser.PasswordLastChanged
> WScript.Echo "Password last changed: " & dtmValue
>
> but instead I want to have the script ask for the username, and OU's
> (iff possible) instead of me having to edit the script file.
>
> Thanks
>
>

AddThis Social Bookmark Button