LiveCycle - Leveraging Windows PowerShell
PowerShell is Microsoft's new scripting environment for Windows, formerly code-named Monad. It will be native to the upcoming Windows Server 2008. Microsoft has let it be known that this will be the system administration environment for Microsoft products going forward.
It is based on the .NET framework. It is a shell as well as a scripting language. It is object-based and extensible. It comes with about 100 so-called commandlets whose output can be piped into other commandlets. For current Windows versions, you can download PowerShell 1.0
PowerShell can be used to gather process information. Here is the PowerShell command to display all running processes that are consuming more than 100 MB of RAM (WS=Working Set)
Get-Process | where { $_.WS -gt 100MB }
Here is the command to list all Windows services, sorted by their status, and then by the display name:
Get-Service | Sort-Object status, displayname
Command to list all Windows services that has the term "Adobe" in the Display Name:
Get-Service | Where-Object {$_.displayname -like "*Adobe*"}
Command to display the performance score of the hardware:
Get-Wmiobject win32_winsat | format-table __SERVER, *SCORE –autosize
The following sequence of PowerShell commands lets you query your remote SQL Server 2005 LiveCycle database to get a list of all User Manager domains, provided you have the SQLServer client installed:
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=192.150.23.6;Database=lc_es;user=sa;password=mypassword"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = "SELECT id, commonname, domainname, syncstate FROM lc_db_usr.EDCPRINCIPALDOMAINENTITY ORDER BY domainname"
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
Return the number of returned records
$SqlAdapter.Fill($DataSet)
Display the returned records
$DataSet.Tables[0]
If the id is only partially displayed, get the full value by passing the record number
$DataSet.Tables[0].rows[2].item("id")
These have been tested to work in Windows Vista 32-bit.
PowerShell blog
Microsoft TechNet Script Center