Powershell for Lotus Notes and Domino…

So I know Lotuscript is available for pretty much anything in Notes & Domino, but we now have Powershell which can be easier to use than Lotuscript.

So here’s how I hooked into a Notes Session using powershell to perform some tasks recently..

Clear-Host
#... Set some variables
$strDominoDir = 'names.nsf'
$strHubServer = 'SERVER1/SVR/LONDON/ORG'
$strUserView = '($Users)' 
 #... Setup the notes Session connection
$notes = new-object -comobject Lotus.NotesSession
$notes.initialize(") 
 #... Get a handle on the Domino Directory
$dbNAB = $notes.GetDatabase( $strHubServer, $strDominoDir, 1 ) 
write-Host $dbNAB.Title ": Database Now Open for business" 
 #... Get a handle on a View from the Domino Directory
$vwUsers = $dbNAB.GetView( $strUserView ) 
Write-Host $vwUsers.Name ": View Now Open for business" 
 #... Find a document by string key and access user attributes
$docUser = $vwUsers.GetDocumentByKey( "John Smith" ) 
Write-Host $docUser.GetItemValue( "mailfile" )

Whats really cool about this is that you can pretty much use Lotuscript calls in much the same way you would normally. This reduces the amount of new code you have to write.

This method is similar to the way a Notes session is started in VBA.

What did I use this for? As part of our Notes upgrade to 8.5..

I piped in all of my users Windows ID’s as the Key in the GetDocumentByKey Command, which in turn returned their mail file paths then added them to an .IND file.

This was then copied to the domino Servers ready to run the Load Convert Task, amongst other actions !

 

Advertisements

9 thoughts on “Powershell for Lotus Notes and Domino…

  1. Pingback: Episode 154 – Josh Heller from Cisco on UCS and PowerShell « PowerScripting Podcast

  2. Is there any way to run fixup, updall, and compact commands from Powershell once you have connected to a database? I’d like to automate some functionality for VIP users.

    • Are you trying to do this to a user’s local config or send commands to remote server? For a local database you can call the exe’s for those commands directly such as “ncompact.exe database.nsf”

      • Was trying to run this on a server. I’ve settled on a bat script in DOS on the server itself. Of course, I’d like to avoid logging into the server itself to run ncompact etc. If I can run it in the server, remotely from my management system, then that would be much better!

    • No, however I did use it a few years back to get a handle on users personal address book from their stored profile and update the server on their location document.. Concepts the same..

  3. Have you ever used powershell to remove users from the nsf ACLs? If so, what method did you use to remove a user from the Acl.

    • To be honest Brian, for that level of action it would probably be easier to update the application ACL using LotuScript. Then once complete you can use the method described in this post to create a powershell wrapper.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s