Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError in serializer.py #155

Open
BiggestSmile opened this issue Aug 2, 2022 · 0 comments
Open

KeyError in serializer.py #155

BiggestSmile opened this issue Aug 2, 2022 · 0 comments

Comments

@BiggestSmile
Copy link

BiggestSmile commented Aug 2, 2022

Hi Jordan!

I'm getting the similar error as in issue #3 and #71.

My code:

import os
from pypsrp.powershell import PowerShell, RunspacePool
from pypsrp.wsman import WSMan

wsman = WSMan(os.environ.get("SPCA_IP", ""),
              username=os.environ.get("DOMAIN", "") + "\\" + os.environ.get("AD_USER", ""),
              password=os.environ.get("AD_PASS", ""),
              ssl=False)

with RunspacePool(wsman) as pool:
    ps = PowerShell(pool)
    script = '''begin {
                        Add-PSSnapin Microsoft.SharePoint.PowerShell
                        Get-SPSite -Identity http://ws2019std-shp/sites/team_site_1 | Get-SPWeb -Limit ALL
                }'''
    ps.add_script(script)
    output = ps.invoke()

Error Traceback:

Traceback (most recent call last):
  File "/content/portal/portal_backend/con_ms_shp_farm/services/examples_pack/04_PSRP.py", line 37, in <module>
    output = ps.invoke()
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 1218, in invoke
    return self.end_invoke()
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 1190, in end_invoke
    self.poll_invoke()
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 1391, in poll_invoke
    responses = self.runspace_pool._receive(self.id, timeout=timeout)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 683, in _receive
    return self._parse_responses(response, pipeline)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 690, in _parse_responses
    messages = self._fragmenter.defragment(responses)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 1634, in defragment
    messages = [Message.unpack(fragment, self.serializer) for fragment in fragments]
  File "/usr/local/lib/python3.9/site-packages/pypsrp/powershell.py", line 1634, in <listcomp>
    messages = [Message.unpack(fragment, self.serializer) for fragment in fragments]
  File "/usr/local/lib/python3.9/site-packages/pypsrp/messages.py", line 208, in unpack
    message_data = serializer.deserialize(message_data)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/serializer.py", line 350, in deserialize
    obj = self._deserialize_dynamic_obj(element, metadata)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/serializer.py", line 685, in _deserialize_dynamic_obj
    value = self.deserialize(adapted_property, clear=False)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/serializer.py", line 228, in deserialize
    return unpack_function(element)
  File "/usr/local/lib/python3.9/site-packages/pypsrp/serializer.py", line 224, in <lambda>
    "Ref": lambda d: self.obj[d.attrib["RefId"]],
KeyError: '18'

Process finished with exit code 1

Collected logs here:
pypsrp.xml.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant