I need this to be able to automatically configure the Lotus Notes client as we are deploying Windows 7. So with that information I will automatically create the text config file that goes inside the notes.ini file.
So let's see how to do it.
#Create the connection
$Connection = New-Object -Com "ADODB.Connection"
$Connection.Provider = "ADsDSOObject"
$Connection.Open("Active Directory Provider")
$Command = New-Object -Com "ADODB.Command"
$Command.ActiveConnection = $Connection
#Create the Query
$Query = "SELECT displayname, uid FROM " + `
"'LDAP://ServerName" + `
"'WHERE uid='$($env:username)'"
#Execute the command
$Command.CommandText = $Query
$Execution = $Command.Execute()
$Execution.movefirst()
$Execution.fields | ? {$_.name -eq "DisplayName"} | select -ExpandProperty Value
That's it.
If you want to get all the information you can change the WHERE line to:
"'WHERE ObjectClass='inetOrgPerson'"
And loop until the end.
do{$Execution.fields; $Execution.movenext()}
while(!$Execution.EOF)
After $Execution.fields | ? {$_.name -eq "DisplayName"} | select -ExpandProperty Value
ReplyDeleteAdd:
Set-Content -Path C:\Temp\notesconfig.txt -Value "Username=$user" -Force
Add-Content -Path C:\Temp\notesconfig.txt -Value "Domino.Server=1"
Add-Content -Path C:\Temp\notesconfig.txt -Value "Domino.Name=ReplaceWithDominoServerName"
Add-Content -Path C:\Temp\notesconfig.txt -Value "Domino.Port=TCPIP"
Add-Content -Path C:\Temp\notesconfig.txt -Value "AdditionalServices=0"
Add-Content -Path C:\ProgramData\Lotus\Notes\Data\notes.ini -Value "ConfigFile=C:\Temp\notesconfig.txt"
Then use Group Policy to run the script the first time a user logs in to a computer.