Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Default params if no input given.
- param (
- [string]$txtFileName="default",
- [int]$duration=0,
- [string]$title="CompanyName IT"
- )
- #Path to message repo
- $msgPath = ("\\namespace\it\deploy\_messages\" + $txtFileName + ".txt")
- #exit early if txt file doesn't exist
- If (-Not (Test-Path $msgPath)) {
- exit 1
- }
- #Get full name and surname of current user
- #Might require .NET 4.6.1 or PS 4.0 to work
- Add-Type -AssemblyName System.DirectoryServices.AccountManagement;
- $user = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current.DisplayName;
- #Combine header "Dear $username" and txt file contents
- $msg = Get-Content -Path $msgPath | Out-String
- $msgFinal = "Dear " + $user + "`n`n" + $msg
- $a = new-object -comobject wscript.shell
- $intAnswer = $a.popup($msgFinal,$duration,$title,0+32+4096)
- If ($intAnswer -eq 1) {
- exit 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement