Error "No snap-ins have been registered ..."

  • 1
  • Question
  • Updated 1 month ago
  • (Edited)
From the CMD prompt, I'm running a .BAT file that calls Powershell to run a .PS1 script that calls ShareFile.  That all works well and transfers my file.  But because I want this all to run unattended, I am launching CMD from a separate script, and in that case it runs the .bat to call the .ps1, but then I get an error when it tries to run the first line of my .ps1 (which is "Add-PSSnapin ShareFile"), with the error saying that "No snap-ins have been registered for Windows PowerShell ...".  Again, this works fine when I run my .bat (which calls the .ps1)  from the CMD prompt directly via user input.   

I am guessing there is some kind of permissions issue, where CMD is successfully calling Powershell, but the privileges are not allowing the snap-in to be recognized (or executed).  Has anyone experienced this type of thing before?
Photo of Sharon Edelmann

Sharon Edelmann

  • 2 Posts
  • 0 Reply Likes
  • frustrated

Posted 3 years ago

  • 1
Photo of Keith Lindsay

Keith Lindsay

  • 211 Posts
  • 40 Reply Likes
Hi Sharon,

Instead of chaining the scripts have you tried running the Bat file with windows scheduler directly?

--Keith
Photo of Sharon Edelmann

Sharon Edelmann

  • 2 Posts
  • 0 Reply Likes
Yes, the .bat will run successfully from Task Scheduler directly.  But I'm hoping to run it all from my Ant-based utility, which runs various other tasks in a series and does all of my error logging in one spot, emails the results, etc.  So if I run my .bat script as a separate step in the Task Scheduler, I miss out on all of that management functionality.

I have also tried calling the .ps1 directly from Ant (cutting out the .bat) and I get the same error ("No snap-ins have been regiestered...").
(Edited)
Photo of Keith Lindsay

Keith Lindsay

  • 211 Posts
  • 40 Reply Likes
Ah, hmm, have you set the properties on the Batch file to always run as admin?  
Photo of Rick Pittser

Rick Pittser

  • 1 Post
  • 0 Reply Likes
This is a very old post, but was a solution ever determined? I am having this same problem.