![Get-CMGStatus Function](https://www.joseespitia.com/wp-content/uploads/2020/01/get-cmgstatus.png)
This small Powershell function can be used to determine if an SCCM client is connected to the Internet or Intranet. It is useful when you have a job that requires some type of network resource and it cannot run while your client is connected to a cloud management gateway. Using this example, you can easily determine the connection with the function and then decide to exit the script and run it at a later time.
Function Get-CMGStatus { <# .SYNOPSIS Queries SCCM connection type to determine if the PC is connected to a CMG #> $ClientInfo = Get-WmiObject -namespace root\ccm -Class ClientInfo If($ClientInfo.InInternet) { Return $True } Else { Return $False } }