Oct 14 2017

PowerShell script to query ADSI and get user object properties #adsi #powershell

# Here is a PowerShell script to query ADSI and to get user account properties and report the results in excel. When I wrote this script, there are three huddles(trial and errors) I had to overcome which I added notes here to save you time. $a = New-Object -comobject Excel.Application $a.visible = $True $b = $a.Workbooks.Add() $c = $b.Worksheets.Item(1) $c.Cells.Item(1,1) = User $c.Cells.Item(1,2) = UserName $c.Cells.Item(1,3) = Home Directory $c.Cells.Item(1,4) = Home Drive $c.Cells.Item(1,5) = Membership $c.Cells.Item(1,6) = Mail $c.Cells.Item(1,7) = Account Disabled $c.Cells.Item(1,8) = Report Time Stamp $d = $c.UsedRange $d.Interior.ColorIndex = 19 $d.Font.ColorIndex = 11 $d.Font.Bold = $True …

Oct 11 2017

Windows PowerShell Module Directory #powershell, #module #directory, #scripting #language, #microsoft, #powershell #module #directory

# PowerShell Module Directory Introduction to PowerShell Modules PowerShell modules are like mini-apps, they have instructions to deliver useful gismos. Configuring the path for the Import-Module cmdlet requires moderately complex preparation, and the purpose of this page is just get readers started. PowerShell Modules Topics You need a known path where your .psm1 modules are stored. I would start by finding $Profile. Then try PSProfilePath. We need to start with the trickiest member of the module family ‘Import’. There are two factors to ensure success of my experiment:a) Creating a simple test module containing PowerShell commands and with a .psm1 …

Sep 3 2017

PowerShell Write-Eventlog Cmdlet #powershell, #write-eventlog, #microsoft, #get-member, #write #eventlog #application, #write #eventlog #system

# PowerShell Write-Eventlog PowerShell Write-Eventlog Cmdlet PowerShell s Write-Eventlog is one of the most difficult cmdlets to master. The problem is that we are asking a script to mimic how the operating system or an application writes to eventlog. For that to be successful we need to understand valid source and EventIDs. PowerShell Write-Eventlog Topics PowerShell Eventlog -List Pre-requisites: Visit Microsoft’s site and download the correct version of PowerShell for your operating system. So that you can focus on the properties of the message, I suggest that you become familiar with Get-Eventlog before graduating to Write-Eventlog. Our first task is …