Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get-WMIObject 0x800706F7 - The stub received bad data - Windows 2008 R2

$
0
0

I am writing a script a query out Citrix environment for the Lotus Notes processes that are running across the farm.  I am passing it the credentials using a password stored in a text file and pulling it in as a secure string.

The problem is when the Get-WMIObject runs i receive and error

Get-WMI-Object " the stub received bad data. (Exception from HRESULT: 0x800706F7 )

Thanks in advance for any help!  If there is a better way to terminate the processes that is more reliable please suggest.  Since it is Citrix i cannot run the Terminate command as the service account or it will kill all users instances of Notes on the server.  Since they are regular users, i cannot run the WMI call or any remote termination as the regular users.

# ==============================================================================================
#
# Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2009
#
# NAME:
#
# AUTHOR: Graham , Justin
# DATE  : 8/20/2013
#
# COMMENT: Here is the process to create the encrypted password file
#$secure = read-host -assecurestring
#$encrypted = convertfrom-securestring -secureString $secure
#$encrypted | set-content <file location>
#
# ==============================================================================================

Add-PSSnapin citrix.xenapp.commands

#Gets current user running the script
$currentuser = [Environment]::UserName

#WMI cannot be run as seperate credentials locally, who cares, they have access to kill local processes they own!
Stop-Process -Name *notes*

#Set Servcie Account USer ID
$SPAdmin = "<domain>\<adminID>"
#Gets the password from file and encrypts it
#$password = <testpassword>
#$password = Read-Host -AsSecureString
#$password_Secure = ConvertTo-SecureString $password -AsPlainText -Force
$Password_Secure = Get-Content <PATH TO SECURE STRING>\securestring.txt | ConvertTo-SecureString -asplaintext -force
#Stores the UserID / password combo
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $SPAdmin, $Password_Secure
#Find the user in the farm ( required read access to console )
foreach ($serversname in get-xasession -account <domain>\$currentuser)
{
#Kills the processes for all running instances another another like *notes*
$processes = (Get-WmiObject -class win32_process -ComputerName $ServersName.ServerName -Credential $Credential | where{$_.ProcessName -like '*notes*'})
 foreach ($process in $processes)
 { If ($process.getowner().user = $currentuser )
  {
  $process.terminate()
  }
 }
}


sleep -seconds 10
Start-Process 'C:\Program Files (x86)\ibm\Lotus\Notes\notes.exe'


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>