Hi Tanya,
You can write your own custom action to check if the user belongs to
Domain Users group and write into log file.
To do that you can run a PowerShell script, something like this:
Code: Select all
$user = $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$groups = 'Domain Users'
foreach ($group in $groups) {
$members = Get-ADGroupMember -Identity $group -Recursive | Select -ExpandProperty SamAccountName
If ($members -contains $user) {
Write-Output "$user is a member of $group"
} Else {
Write-Output "$user is not a member of $group"
}
}
Feel free to make any changes to the above script. You can write to the MSI installation log by simply using the "Write-Output" cmdlet into your PowerShell custom action code.
If you want to display a message, then you can use the predefined
Display message box custom action. In the above script you can set a property that can be further used to condition the execution of the custom action that display the message.
If you want to display the message directly from the PowerShell script, please use the below code:
Code: Select all
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.MessageBox]::Show("$env:USERNAME" + " is not part of Domain Users group.")
Hope this helps. If you have any other questions, please don't hesitate to contact us.
Best regards,
Dan