Updating com+ component username/password in PowerShell

Here's a little PowerShell script that will update the username and password on a com+ component. Useful when domain accounts are used as identities on com+ objects on a bunch of systems and you need to change the username and password.

write-host Starting
$catalog = New-Object -comobject COMAdmin.COMAdminCatalog
$applications = $catalog.GetCollection("Applications")
$applications.Populate()
write-host "Collection populated"

foreach ($application in $applications)
{
    if ($application.Name -eq "COM SERVICE NAME")
    {
        $application.Value("Identity") = "username"
        $application.Value("Password") = "password"
        $result = $applications.SaveChanges()
        if (-not $result -eq 1)
        {
            write-error "Username/Password was not changed successfully"
        }
    }
}
write-host "Completed."