Advertisement
Guest User

Untitled

a guest
May 25th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. # Setup the context information
  2. $mContext = New-Object System.Management.ManagementNamedValueCollection
  3. $mContext.Add( "__ProviderArchitecture", 64)
  4. $mContext.Add( "__RequiredArchitecture", $true)
  5.  
  6. # Setup the Authrntification object
  7. $ConOptions = New-Object System.Management.ConnectionOptions
  8. #$ConOptions.Username = "computernameadministrateur" # Should be used for remote access
  9. #$ConOptions.Password = "toto"
  10. $ConOptions.EnablePrivileges = $true
  11. $ConOptions.Impersonation = "Impersonate"
  12. $ConOptions.Authentication = "Default"
  13. $ConOptions.Context = $mContext
  14.  
  15. # Setup the management scope (change with the computer name for remote access)
  16. $mScope = New-Object System.Management.ManagementScope( `
  17. "\localhostrootcimV2", $ConOptions)
  18.  
  19. $mScope.Connect()
  20.  
  21. # Query
  22. $queryString = "SELECT * From Win32_PerfFormattedData_NETFramework_NETCLRMemory"
  23. $oQuery = New-Object System.Management.ObjectQuery ($queryString)
  24. $oSearcher = New-Object System.Management.ManagementObjectSearcher ($mScope, $oQuery)
  25. $oResult = $oSearcher.Get();
  26.  
  27. $oResult.Name # only for simple check that current code snippet gives
  28. # the same results from both 32 and 64 -bit version of PowerShell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement