开发者

Can't run my own powershell Cmdlet because access to "Templates" folder is denied?

I'm starting out with Powershell, and I'm having a strange error that I can't find much details about with our friend Mr. Google.

And before you ask, yes, I am definitely running Powershell as an Administrator.

I created a simple Cmdlet that counts files of a specified extension in the current directory.

I can build and run installutil fine.

I can see the snap-in when I Call Get-PSSnapin -Registered, and I can add it using Add-PSSnapin

But when I run my cmdlet, I get the following error:

PS C:\work\Enterprise> Get-PSSnapin -Registered


Name        : FileCountCmdlet
PSVersion   : 2.0
Description : Returns a file count



PS C:\work\> Add-PSSnapin FileCountCmdlet
PS C:\work\> Get-FileCount
Get-FileCount : Access to the path 'C:\Users\{My-User-Name}\Templates' is denied.
At line:1 开发者_StackOverflow中文版char:14
+ Get-FileCount <<<<
    + CategoryInfo          : NotSpecified: (:) [Get-FileCount], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,FileCount.FileCountCmdlet

Any thoughts or help would be greatly appreciated!


It sounds like you might be running into what this link describes:

Junction Points

http://www.svrops.com/svrops/articles/jpoints.htm

If so, you'll need to update your cmdlet to skip over these junction points.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜