|
| 1 | +Function ConnectLocalMDMWMIBridgeNamespace(ByRef objSWbemServicesMDMWMIBridgeNamespace) |
| 2 | + 'region FunctionMetadata ####################################################### |
| 3 | + ' Connects to the local computer's mobile device management (MDM) WMI Bridge |
| 4 | + ' Namespace ("root\cimv2\mdm\dmmap"). Requires administrative rights for a |
| 5 | + ' successful connection |
| 6 | + ' |
| 7 | + ' The function returns 0 upon success. When the function fails, it returns a negative |
| 8 | + ' integer between -1 and -10 (inclusive), depending on the specific failure that occurs. |
| 9 | + ' |
| 10 | + ' Example: |
| 11 | + ' intReturnCode = ConnectLocalMDMWMIBridgeNamespace(objSWbemServicesMDMWMIBridgeNamespace) |
| 12 | + ' If intReturnCode = 0 Then |
| 13 | + ' ' Successfully connected to the local computer's MDM WMI Bridge Namespace |
| 14 | + ' End If |
| 15 | + ' |
| 16 | + ' Version: 1.0.20230424.0 |
| 17 | + 'endregion FunctionMetadata ####################################################### |
| 18 | + |
| 19 | + 'region License ################################################################ |
| 20 | + ' Copyright 2023 Frank Lesniak |
| 21 | + ' |
| 22 | + ' Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 23 | + ' this software and associated documentation files (the "Software"), to deal in the |
| 24 | + ' Software without restriction, including without limitation the rights to use, |
| 25 | + ' copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
| 26 | + ' Software, and to permit persons to whom the Software is furnished to do so, |
| 27 | + ' subject to the following conditions: |
| 28 | + ' |
| 29 | + ' The above copyright notice and this permission notice shall be included in all |
| 30 | + ' copies or substantial portions of the Software. |
| 31 | + ' |
| 32 | + ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 33 | + ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 34 | + ' FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 35 | + ' COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 36 | + ' AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 | + ' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 | + 'endregion License ################################################################ |
| 39 | + |
| 40 | + 'region DownloadLocationNotice ################################################# |
| 41 | + ' The most up-to-date version of this script can be found on the author's GitHub |
| 42 | + ' repository at https://github.com/franklesniak/sysadmin-accelerator |
| 43 | + 'endregion DownloadLocationNotice ################################################# |
| 44 | + |
| 45 | + 'region Acknowledgements ####################################################### |
| 46 | + ' Michael Niehaus, who wrote the script Get-WindowsAutoPilotInfo, which is where I |
| 47 | + ' learned about this WMI namespace: |
| 48 | + ' https://www.powershellgallery.com/packages/Get-WindowsAutoPilotInfo/ |
| 49 | + ' |
| 50 | + ' Peter van der Woude, who told me that the WMI namespace root\cimv2\mdm\dmmap is |
| 51 | + ' the MDM WMI Bridge provider: |
| 52 | + ' https://www.petervanderwoude.nl/post/windows-10-mdm-powershell-scripting/ |
| 53 | + 'endregion Acknowledgements ####################################################### |
| 54 | + |
| 55 | + 'region DependsOn ############################################################## |
| 56 | + ' ConnectLocalWMINamespace() |
| 57 | + 'endregion DependsOn ############################################################## |
| 58 | + |
| 59 | + Dim intFunctionReturnCode |
| 60 | + intFunctionReturnCode = 0 |
| 61 | + |
| 62 | + intFunctionReturnCode = ConnectLocalWMINamespace(objSWbemServicesMDMWMIBridgeNamespace, "root\cimv2\mdm\dmmap", Null) |
| 63 | + |
| 64 | + ConnectLocalMDMWMIBridgeNamespace = intFunctionReturnCode |
| 65 | +End Function |
0 commit comments