Author Posts

July 23, 2018 at 11:16 pm

Hi guys.. not sure if this will even fall under PowerShell but I am looking for a way to display a simple popup with some contact information and IP address of the host.

Currently, I am using 'Wscript.Shell' which is nice and fast but very limiting.

Right now they are asking for a bunch of stuff that is not supported by this but I wanted to see if anyone had any better ideas.

They are wanting to add a logo, hyperlink (support URL), copy to clipboard, and god only knows what else before it is approved.

This is my script currently, but I was wondering if there was a better way, perhaps something like calling an IE window of a fixed size that contains this info and would allow images and hyperlinks etc...

#Create Vars
$Username = $env:USERNAME.ToUpper()
$Computername = $env:COMPUTERNAME.ToUpper()
$ComputerDomain = (Get-WmiObject win32_computersystem).Domain
$IPAddress = ((Get-NetIPAddress -AddressFamily IPv4 -AddressState Preferred) | Where InterfaceAlias -NotMatch "Loopback*") -join ';   '
$SCCMAgent = (Get-Service -DisplayName 'sms agent host').status
$OS = (Get-CimInstance Win32_OperatingSystem).Caption
$SDcontact = "http:\\website.com"

#Create Window and Collect Input
$wshell = New-Object -ComObject Wscript.Shell
$Answer = $wshell.Popup("IP Address:`t$IPAddress`n`nUsername:`t$Username`nComputer:`t$Computername`nDomain:`t`t$ComputerDomain`nSCCM Agent:`t$SccmAgent`nOS:`t`t$OS`n`nContact:`t`t$SDcontact`n`nWould you like to copy this information to the clipboard",0,"Title",4)

#Check Answer
If($Answer -eq "6"){
Set-Clipboard -Value "IP Address: $IPAddress"
Set-Clipboard -Value "Username: $Username" -Append
Set-Clipboard -Value "Computer Name: $Computername" -Append
Set-Clipboard -Value "Domain: $ComputerDomain" -Append
Set-Clipboard -Value "SCCM Agent: $SCCMAgent" -Append
Set-Clipboard -Value "OS: $OS" -Append
#Popup provides enough time for the above to run.
$wshell.Popup("Information has been copied to the clipboard",0,"Success",0)
}

July 24, 2018 at 7:01 am

Have a look at the link below. A WPF form may give you more options than calling $wshell.popup

http://vcloud-lab.com/entries/powershell/powershell-wpf-gui-linklabel-hyperlink-demo

July 24, 2018 at 9:13 pm

Thanks. I think i'm on the right path now