I'm looking to be able to call this a function. If VPN check = true then execute the script. Ideally, I would like to check the VPN status and then execute the whole script. After this runs and returns true or fault I don't know how to reference it moving forward. This seemed simple when I was trying to come up with a plan. Any help would be much appreciated, I am very much a rookie writing powershell.
#check VPN
$vpnCheck = Get-WmiObject -Query "Select Name,NetEnabled from Win32_NetworkAdapter where
(Name like 'Juniper Networks Virtual Adapter' or Name like 'PANGP Virtual Ethernet
Adapter' or Name like '%VPN%') and NetEnabled='True'"
# If it returns a value it's true,
# if it does not return a value it's false.
$vpnCheck = [bool]$vpnCheck
# Check if $vpnCheck is true or false.
if ($vpnCheck) {
return $vpnCheck
exit(0)
}
else {
return $vpnCheck
exit(1)