Hey all.<\/p>\n
I have here a power shell VPN script that I wish to make it show an windows message box saying:<\/p>\n
“Please now continue to open outlook or shares” with OK<\/p>\n
On first connect, however on running the bat file seems to show errors<\/p>\n
What am i doing worng if you could help it would useful to me.<\/p>\n
autostart.bat\n\npowershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file \"C:\\eg\\AutoVPN.ps1\"\n\n<\/code><\/pre>\nAutoVPN.ps1\n\nAdd-Type -AssemblyName PresentationFramework\n[System.Windows.MessageBox]::Show('Please now continue to open outlook or shares')\nwhile ($true)\n {\n $vpnname = \"VPN\"\n $vpnusername = \"name.last\"\n $vpnpassword = \"password\"\n $vpn = Get-VpnConnection | where {$_.Name -eq $vpnname}\n if ($vpn.ConnectionStatus -eq \"Disconnected\")\n {\n $cmd = $env:WINDIR + \"\\System32\\rasdial.exe\"\n $expression = \"$cmd \"\"$vpnname\"\" $vpnusername $vpnpassword\"\n Invoke-Expression -Command $expression\n }\n start-sleep -seconds 30\n }\n<\/code><\/pre>\n<\/use><\/svg>vpn.jpg<\/span>800×237 48.4 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>\n<\/use><\/svg>vpn.jpg<\/span>977×290 68.2 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":5,"answerCount":9,"datePublished":"2019-06-17T14:08:39.000Z","author":{"@type":"Person","name":"olivermitchell","url":"https://community.spiceworks.com/u/olivermitchell"},"suggestedAnswer":[{"@type":"Answer","text":"Hey all.<\/p>\nI have here a power shell VPN script that I wish to make it show an windows message box saying:<\/p>\n“Please now continue to open outlook or shares” with OK<\/p>\nOn first connect, however on running the bat file seems to show errors<\/p>\nWhat am i doing worng if you could help it would useful to me.<\/p>\nautostart.bat\n\npowershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file \"C:\\eg\\AutoVPN.ps1\"\n\n<\/code><\/pre>\nAutoVPN.ps1\n\nAdd-Type -AssemblyName PresentationFramework\n[System.Windows.MessageBox]::Show('Please now continue to open outlook or shares')\nwhile ($true)\n {\n $vpnname = \"VPN\"\n $vpnusername = \"name.last\"\n $vpnpassword = \"password\"\n $vpn = Get-VpnConnection | where {$_.Name -eq $vpnname}\n if ($vpn.ConnectionStatus -eq \"Disconnected\")\n {\n $cmd = $env:WINDIR + \"\\System32\\rasdial.exe\"\n $expression = \"$cmd \"\"$vpnname\"\" $vpnusername $vpnpassword\"\n Invoke-Expression -Command $expression\n }\n start-sleep -seconds 30\n }\n<\/code><\/pre>\n<\/use><\/svg>vpn.jpg<\/span>800×237 48.4 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>\n<\/use><\/svg>vpn.jpg<\/span>977×290 68.2 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":5,"datePublished":"2019-06-17T14:08:39.000Z","url":"https://community.spiceworks.com/t/powershell-vpn-file-with-windows-message-box/716732/1","author":{"@type":"Person","name":"olivermitchell","url":"https://community.spiceworks.com/u/olivermitchell"}},{"@type":"Answer","text":"If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
AutoVPN.ps1\n\nAdd-Type -AssemblyName PresentationFramework\n[System.Windows.MessageBox]::Show('Please now continue to open outlook or shares')\nwhile ($true)\n {\n $vpnname = \"VPN\"\n $vpnusername = \"name.last\"\n $vpnpassword = \"password\"\n $vpn = Get-VpnConnection | where {$_.Name -eq $vpnname}\n if ($vpn.ConnectionStatus -eq \"Disconnected\")\n {\n $cmd = $env:WINDIR + \"\\System32\\rasdial.exe\"\n $expression = \"$cmd \"\"$vpnname\"\" $vpnusername $vpnpassword\"\n Invoke-Expression -Command $expression\n }\n start-sleep -seconds 30\n }\n<\/code><\/pre>\n<\/use><\/svg>vpn.jpg<\/span>800×237 48.4 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>\n<\/use><\/svg>vpn.jpg<\/span>977×290 68.2 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":5,"answerCount":9,"datePublished":"2019-06-17T14:08:39.000Z","author":{"@type":"Person","name":"olivermitchell","url":"https://community.spiceworks.com/u/olivermitchell"},"suggestedAnswer":[{"@type":"Answer","text":"Hey all.<\/p>\nI have here a power shell VPN script that I wish to make it show an windows message box saying:<\/p>\n“Please now continue to open outlook or shares” with OK<\/p>\nOn first connect, however on running the bat file seems to show errors<\/p>\nWhat am i doing worng if you could help it would useful to me.<\/p>\nautostart.bat\n\npowershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file \"C:\\eg\\AutoVPN.ps1\"\n\n<\/code><\/pre>\nAutoVPN.ps1\n\nAdd-Type -AssemblyName PresentationFramework\n[System.Windows.MessageBox]::Show('Please now continue to open outlook or shares')\nwhile ($true)\n {\n $vpnname = \"VPN\"\n $vpnusername = \"name.last\"\n $vpnpassword = \"password\"\n $vpn = Get-VpnConnection | where {$_.Name -eq $vpnname}\n if ($vpn.ConnectionStatus -eq \"Disconnected\")\n {\n $cmd = $env:WINDIR + \"\\System32\\rasdial.exe\"\n $expression = \"$cmd \"\"$vpnname\"\" $vpnusername $vpnpassword\"\n Invoke-Expression -Command $expression\n }\n start-sleep -seconds 30\n }\n<\/code><\/pre>\n<\/use><\/svg>vpn.jpg<\/span>800×237 48.4 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>\n<\/use><\/svg>vpn.jpg<\/span>977×290 68.2 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":5,"datePublished":"2019-06-17T14:08:39.000Z","url":"https://community.spiceworks.com/t/powershell-vpn-file-with-windows-message-box/716732/1","author":{"@type":"Person","name":"olivermitchell","url":"https://community.spiceworks.com/u/olivermitchell"}},{"@type":"Answer","text":"If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
autostart.bat\n\npowershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file \"C:\\eg\\AutoVPN.ps1\"\n\n<\/code><\/pre>\nAutoVPN.ps1\n\nAdd-Type -AssemblyName PresentationFramework\n[System.Windows.MessageBox]::Show('Please now continue to open outlook or shares')\nwhile ($true)\n {\n $vpnname = \"VPN\"\n $vpnusername = \"name.last\"\n $vpnpassword = \"password\"\n $vpn = Get-VpnConnection | where {$_.Name -eq $vpnname}\n if ($vpn.ConnectionStatus -eq \"Disconnected\")\n {\n $cmd = $env:WINDIR + \"\\System32\\rasdial.exe\"\n $expression = \"$cmd \"\"$vpnname\"\" $vpnusername $vpnpassword\"\n Invoke-Expression -Command $expression\n }\n start-sleep -seconds 30\n }\n<\/code><\/pre>\n<\/use><\/svg>vpn.jpg<\/span>800×237 48.4 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>\n<\/use><\/svg>vpn.jpg<\/span>977×290 68.2 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":5,"datePublished":"2019-06-17T14:08:39.000Z","url":"https://community.spiceworks.com/t/powershell-vpn-file-with-windows-message-box/716732/1","author":{"@type":"Person","name":"olivermitchell","url":"https://community.spiceworks.com/u/olivermitchell"}},{"@type":"Answer","text":"If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
AutoVPN.ps1\n\nAdd-Type -AssemblyName PresentationFramework\n[System.Windows.MessageBox]::Show('Please now continue to open outlook or shares')\nwhile ($true)\n {\n $vpnname = \"VPN\"\n $vpnusername = \"name.last\"\n $vpnpassword = \"password\"\n $vpn = Get-VpnConnection | where {$_.Name -eq $vpnname}\n if ($vpn.ConnectionStatus -eq \"Disconnected\")\n {\n $cmd = $env:WINDIR + \"\\System32\\rasdial.exe\"\n $expression = \"$cmd \"\"$vpnname\"\" $vpnusername $vpnpassword\"\n Invoke-Expression -Command $expression\n }\n start-sleep -seconds 30\n }\n<\/code><\/pre>\n<\/use><\/svg>vpn.jpg<\/span>800×237 48.4 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>\n<\/use><\/svg>vpn.jpg<\/span>977×290 68.2 KB<\/span><\/use><\/svg><\/div><\/a><\/div><\/p>","upvoteCount":5,"datePublished":"2019-06-17T14:08:39.000Z","url":"https://community.spiceworks.com/t/powershell-vpn-file-with-windows-message-box/716732/1","author":{"@type":"Person","name":"olivermitchell","url":"https://community.spiceworks.com/u/olivermitchell"}},{"@type":"Answer","text":"If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n