You have the source code for that script. If not, it's here: Get-WindowsAutoPilotInfo.ps1
Line 211 looks like this:
$devDetail = (Get-CimInstance -CimSession $session -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND ParentID='./DevDetail'")
Assuming you're running it using to get data from "localhost", the CIM session is created like this (on line 199):
$session = New-CimSession