Executing scripts on SharePoint Management Shell

This topic contains 5 replies, has 3 voices, and was last updated by  Max Kozlov 3 months, 1 week ago.

  • Author
    Posts
  • #78716

    Daniel
    Participant

    Good afternoon everyone,
    I'm looking for a script to apply permissions to folders inside Sharepoint, but I'm not even able to run tests because powershell does not run some scripts, the main error is when I execute any command like this: "$ site = new-object Microsoft.SharePoint.SPSite (" https://contoso.sharepoint.com/ ")", Shell brings me:
    new-object: Can not find the type [Microsoft.SharePoint.SPSite]: Make sure the assembly containing the type is loaded.

    I can't import modules, and can't add Snapin, when I run: "Add-PSSnapin Microsoft.SharePoint.PowerShell", Shell brings me:
    Add-PSSnapin: No snap-ins were registered for Windows PowerShell version 5.

    That is, I can not do anything on account of not loading some assembly modules.
    Could someone give me a help regarding this please?

    Thanks in advance.

  • #78719

    Don Jones
    Keymaster

    So, I'm sure you've checked, but just to be thorough – are you certain that the SharePoint snapin is installed on the computer? You'd get that by installing the SP management tooling, like its admin console, on your system. That should also be what installs the SharePoint .NET Framework bits are installed.

    • #78722

      Daniel
      Participant

      Yes, i've installed: the SharePoint Online Management Shell, the msoid.exe, Sharepoint client components (SDK), but I can't execute the Snapin like this command: "Add-PSSnapin Microsoft.SharePoint.PowerShell", because Shell brings me:
      Add-PSSnapin: No snap-ins were registered for Windows PowerShell version 5.

  • #78725

    Don Jones
    Keymaster

    That kind of makes me think the snap in isn't registering as v5 compatible. I don't know a ton about how SharePoint structures that – and I still can't believe they're using a snap in and not a module! But it's entirely possible that it isn't v5 compatible. I know it was originally developed for v3.

    • #78728

      Daniel
      Participant

      Oh Gosh, I really don't know what can I do to resolve this situation, I'm working in it for 2 weeks. So, thank you so much, I'll try with V.3

  • #78737

    Max Kozlov
    Participant

    you do not write which versions of sharepoint and PS you use (PSv5 found on context)
    if sharepoint v2010
    try to launch `powershell -version 2`

You must be logged in to reply to this topic.