Check for INI value and modify if there, add if not, in notes.ini file

First off, I am OK with powershell but not anywhere close to an expert. Typically if I find code that is close I can make it work but sometimes like right now I get stuck. I am trying to do a few things in a script. We are migrating from Notes to Outlook (Finally) and I have a PS script that does all the required changes EXCEPT checking the notes.ini file for each user for “DontCheckDefaultMail” If not there write it, if there check the value if “1” leave it alone, of “0” change to “1”

here is the chunk of code I am trying to use but I am being prompted to “supply values for the following parameters: Process” Im at a loss as to what it is asking for.

This code is a combo of code from a couple different sources, so its 100% possible that its all goofed up :slight_smile: What I an trying, and failing, to do is read through all user profiles and look for AppData\Local\IBM\Notes\data\notes.ini, If found read the INI file and look for “DontCheckDefaultMail”, what I need it to then do is… If not found add it with a value of “1”, if found and value is “1” leave it along, If value not “1” set it to “1”. I know my script currently doesnt do all of these items, but I can’t even get it to run currently.

$Destination = ‘C:\Users*\AppData\Local\IBM\Notes\data’
Get-ChildItem $Destination | ForEach-Object
$files = Get-ChildItem -Path “$Destination\notes.ini”
foreach ($file in $files)
#$newfilename = $file.fullname -replace “.ini”, “-2.ini”
Get-Content $file |
ForEach {

						$_.Replace('DontCheckDefaultMail=0 ', 'DontCheckDefaultMail=1')
					} | Out-File $file

You could try stepping through each line to verify where you are being prompted. Usually the error will tell you the line and character position the error occurred at.

It is also possible to consolidate some of the Get-ChildItem statements.

If you try:

$NotesDataPath = 'C:\Users\*\AppData\Local\IBM\Notes\Data'
$Files = Get-ChildItem -Path $NotesDataPath -Filter "notes.ini"

That would condense some of the code at the start. Resume your code at the foreach ($file in $files)… statement. Does that help remove the parameter prompt?

Because I have done Notes > Exchange conversions, I feel your pain. The error is occurring because you are never checking to see if a file actually exists, so when you pipe to Out-File, it’s null and wants a value. Take a look at this code and test thoroughly before putting into prod.

The fun part here is the $files. We can use WMI to filter out unwanted profiles, build the NotesIniPath and even check to see if the file exists before we ever attempt to loop through the existing INI files. You should see output like this:

LocalPath    NotesIniPath                                        NotesIniExists
---------    ------------                                        --------------
C:\Users\Rob C:\Users\Rob\AppData\Local\IBM\Notes\data\notes.ini           True
#Use WMI to filter out profiles you don't care about.  Typically, I would
#apply date filters (update in last 30 days) as well to eliminate unnecessary
#enumeration.  We also can not only build a path, but check to see if the file exists
$files = gwmi win32_userprofile -Property * -Filter "Special  'True'" | 
         Select LocalPath, 
                @{Name='NotesIniPath';Expression={'{0}\AppData\Local\IBM\Notes\data\notes.ini' -f $_.LocalPath}},
                @{Name='NotesIniExists';Expression={Test-Path -Path ('{0}\AppData\Local\IBM\Notes\data\notes.ini' -f $_.LocalPath)}}

#So you can see what files looks like

#Now we loop for every file that exists
foreach ($file in ($files | Where {$_.NotesIniExists})) {
    #Get-Content reads files as an array for every line, so
    #we loop thru each line, we only want to call a replace if
    #the line starts with DontCheckDefaultMail.  The $content will
    #hold all of the contents and changes of the file
    $content = foreach ($line in (Get-Content -Path $file.NotesIniPath)) {
        if ($line -like 'DontCheckDefaultMail*') {
            $line.Replace('0', '1')
        else {

    #Now we take the content and write that back to the INI file
    $content | Out-File -Path $file.NotesIniPath



Thank you for the reply! I will test this and report back.