title: SCCM cmdlet from a remote PC
body: <p>I'm trying to create a script to query members of a sccm2012 device collection so that I can pipe that into put into maintenance window. I need to run this from a remote machine. </p>
  
  <p>Here's what I have - if I run each line by line it works fine.
  But if I run it as a script continuously fails. If you could point me in the right direction please or solve for me. PS I'm not that good at PS but getting better.</p>
  
  <pre><code>PS F:\Install\Scritps&gt; Enter-PSSession -ComputerName SERVER -ConfigurationName Microsoft.PowerShell32
  
  Import-module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
  
  cd P01:\
  
  Import-module : The specified module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' was not loaded because no 
  valid module file was found in any module directory.
  At line:4 char:1
  + Import-module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConso ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ResourceUnavailable: (C:\Program File...ionManager.psd1:String) [Import-Module], FileNotFoundException
      + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
  
  cd : Cannot find drive. A drive with the name 'P01' does not exist.
  At line:6 char:1
  + cd P01:\
  + ~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (P01:String) [Set-Location], DriveNotFoundException
      + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
  </code></pre>