Execute a command with Powershell using Win32_Process


$cmd=“xcopy c:1.txt c:temp1.txt /A”


$server=“.”


$user=“domainuserName”


$pass=“p@ssw0rd”


$process = [WMIClass]“\$serverROOTcimv2:Win32_Process”


#$process.psbase.Scope.Options.userName=$user


#$process.psbase.Scope.Options.Password=$pass


#$process.psbase.Scope.Options.Impersonation = [System.Management.ImpersonationLevel]::Impersonate


#$process.psbase.Scope.Options.Authentication = [System.Management.AuthenticationLevel]::PacketPrivacy


$process.Create($cmd)


# get process id and returnValue


$process.ProcessId


$process.ReturnValue

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: