Closed altamiro closed 3 years ago
PowerShell returns an object back with your properties and by default Python doesn't know how to format them. You can access those properties under output[0].extended_properties
or output[0].adapted_properties
. Both of those attributes are a dictionary with the key being the name of the property and the value being the value. I've got plans to try and make all this easier to manage within python but right now that's in the really early stages.
So you have 3 options
ConvertTo-Json
so the output is a string that you can load into PythonInvoke-Expression
so PowerShell formats the output for you.The last option is what is done for the high level client https://github.com/jborean93/pypsrp/blob/c70487480cbb651a89ee7d3efe5dfd21014ecc92/pypsrp/client.py#L212-L215. It wraps the command, in your case Get-Mailbox -ResultSize 10
inside Invoke-Expression and makes sure the output from that is a string to mimick what PowerShell would usually display on it's console.
I am the local Exchange, how should I access Exchange shell to make the get-Mailbox work.
Python: wsman = WSMan(server="ex.test.com",port=80,path="powershell",username=username, password=pwd,ssl=False) Error:SpnegoError (4294967295): [WinError -2146893039] 无法为身份验证与颁发机构取得联系。, Context: Processing security token
Powershell: New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://ex.test.com/powershell/" -Credential $Credentials -Authentication Kerberos -Name ex
@K-V4 the error you have is SEC_E_NO_AUTHENTICATING_AUTHORITY 0x80090311
No authority could be contacted for authentication. The domain name of the authenticating party could be wrong, the domain could be unreachable, or there might have been a trust relationship failure.
What this usually means is the process cannot reach the active directory domain controller and start the Kerberos authentication process. I'm not sure why PowerShell itself is working.
Hi
how to add this command "Get-Mailbox -ResultSize 10 | Select id, RecipientType, RecipientTypeDetails, PrimarySmtpAddress" using pypsrp and getting the return
My code that I use as an example
` wsman = WSMan(server="outlook.office365.com", port=443, path="powershell-liveid", auth="basic", username=username, password=password, cert_validation=False)
`
Thanks for the help