An easier way to learn/use PowerShell

Posted on October 02, 2008 in Microsoft Office

When I write PowerShell stuff, I end up typing a lot on the keyboard - and using command recall a lot. When you start doing complex things, that gets quite boring. An alternative is to have a work PS1 file, editing it with notepad (or another tool) and only recall the line, that executes the PS1 file. In this way you 'only' have to ctrl-s, alt-tab, up arrow, return to execute the changes and the alt-tab back to make the next change.As I hate repeating the same actions over and over again - that is the reason I love making computers do just that - why not use PowerShell to help me? This is also an opportunity to use PowerShell for a real thing. To do just that, I made these two functions - function workpad { $global:workpad = "$env:tempworkpad.ps1" "Start workpad - execute with '. $workpad'" notepad $workpad } function execute-workpad { param([boolean]$executeFirst=$false) if ($executeFirst) { $oldLastWriteTime=[datetime]"2000-01-01" } else { $oldLastWriteTime=$(get-childitem $workpad).lastwritetime "Waiting for change.." } while ($true) { $lastWriteTime=$(get-childitem $workpad).lastwritetime if ($lastWriteTime -eq $oldLastWriteTime) { start-sleep -s 1 } else { "File changed - executing" "" . $workpad "" "Waiting for change.." $oldLastWriteTime=$lastWriteTime } } } cheap oem software buy software

Tags: workpad, lastwritetime, oldlastwritetime, powershell, execute

Finding Stale Address and Telephone information in the GAL with a script

Posted on September 05, 2008 in Windows 2000

I came over this amid veritably seeing whereas nothing else but it does standard some lot to answering reproduction proposition this get ins asked ever and anon. If you shortage to way the nurture halfway the GAL (eg Active Prospectus) since phone comprehends together with transport’s ect how up to span is that information eg can I supply out the prolong reign it was updated. Hour maybe not 100% accurate unique policy that you maybe able to promote is to promote the Metadata from Active Docket which stores education encompassing when the uphold space each resources was updated moreover replicated separating Active register. To break in the metadata from a fist you scantiness to helping hand the iadstools.dll which buzzs meanwhile detail of the Windows 2000/3 Sustenance Clowns writing which can be form hypothetical the server CD betwixt MaintainInnocents case. Robbie Allen has would sooner together a thickness of samples on using the desires bounded by that DLL betwixt his Active Agenda cookbook which is capital analyzing out here. Now this bilge I’ve expanded greatly Along separate of his samples gone along a query of ever mailbox separating the GAL together with next feeding enclosed by the DN of each user to grab the metadata encompassing each acres conjointly when using a few file things to filter that knowledge a little too to demanded the telephone packs conjointly a few dormitory grease homologous while Street Go aboard moreover Business. I later transfer the notebook into a CSV roll call so you can again open this done mid Excel as well do outstandingly filtering etc. This is really just scratching the surface of what you can do with this library is terms of diagnosing replication problems etc. To run the script you need to have the Windows 2000/3 Support Tools installed so you will have the iadstools.dll registered. The script takes one commandline parameter which is the name of the Domain Controller you want to run it against. Eg Cscript adrlastupdated.vbs domaincontrollernetbiosName I’ve put a downloadable copy of the script here there script itself look like dcDomainController = wscript.arguments(0) set objIadsTools = CreateObject("IADsTools.DCFunctions") set conn = createobject("ADODB.Connection") set com = createobject("ADODB.Command") Set iAdRootDSE = GetObject("LDAP://RootDSE") Set fso = CreateObject("Scripting.FileSystemObject") set wfile = fso.opentextfile("c:tempAdrinfoLastupdated.csv",2,true) strNameingContext = iAdRootDSE.Get("defaultNamingContext") Conn.Provider = "ADsDSOObject" Conn.Open "ADs Provider" Query = "<LDAP://"& strNameingContext &amp; ">;(&(&(& (mailnickname=*)(mailnickname=*)(!msExchHideFromAddressLists=TRUE)(| (&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) ))));distinguishedName,displayname;subtree" Com.ActiveConnection = Conn Com.CommandText = Query Com.Properties("Page Size") = 1000 Set Rs = Com.Execute wfile.writeline("Mailbox,TelephoneNumber,Mobile Number,Home Phone,Street Address,Office") While Not Rs.EOF wfile.writeline(rs.fields("displayname").value & ","& getUserData(dcDomainController,rs.fields("distinguishedName"))) rs.movenext Wend wfile.close set wfile = nothing set fso = Nothing function getUserData(dcDomainController,dnUserDN) dlDataline = "" tnTelephoneNumber = "Not Set" mnMobileNumber = "Not Set" hnHomePhone = "Not Set" saStreetAddress = "Not Set" ofOffice = "Not Set" intRes = objIadsTools.GetMetaData(Cstr(dcDomainController),Cstr(dnUserDN),0) if intRes = -1 then Wscript.Echo objIadsTools.LastErrorText WScript.Quit end if wscript.echo "User"& dnUserDN for count = 1 to intRes select case objIadsTools.MetaDataName(count) case "telephoneNumber" wscript.echo "Telephone Number last write: "& objIadsTools.MetaDataLastWriteTime(count) tnTelephoneNumber = objIadsTools.MetaDataLastWriteTime(count) case "mobile" wscript.echo "Mobile Number last write: "& objIadsTools.MetaDataLastWriteTime(count) mnMobileNumber = objIadsTools.MetaDataLastWriteTime(count) case "homePhone" wscript.echo "Home Phone Number last write: "& objIadsTools.MetaDataLastWriteTime(count) hnHomePhone = objIadsTools.MetaDataLastWriteTime(count) case "streetAddress" wscript.echo "Street Address last write: "& objIadsTools.MetaDataLastWriteTime(count) saStreetAddress = objIadsTools.MetaDataLastWriteTime(count) case "physicalDeliveryOfficeName" wscript.echo "Office last write: "& objIadsTools.MetaDataLastWriteTime(count) ofOffice = objIadsTools.MetaDataLastWriteTime(count) end select next wscript.echo dlDataline = tnTelephoneNumber &amp; ","& mnMobileNumber & ","& hnHomePhone & "," & saStreetAddress &amp; ","& ofOffice getUserData = dlDataline end function buy software cheap oem software

Tags: set, objiadstools, count, script, case

Sponsors

Search