2014-09-11 92 views
0

我在写使用WASP的powershell查询。如何在不重新安装的情况下永久使用WASP?

但我想用WASP每次我必须做的:

C:\ WINDOWS \ SYSTEM32 \ WindowsPowerShell \ V1.0>powershell.exe Install.ps1 -Force

然后我得到这样的结果:

enter image description here

当他们说:我P中运行这个owershell_ise.exe:

Add-PSSnapin WASP

现在 - 我可以使用WASP编写查询。

问题

下一个时候我开始Powershell_ise.exe并尝试调用脚本:

我得到这个错误:

enter image description here

  • 我不为了使用WASP,不想每次都安装它。我能做些什么才能使Powershell_ise.exe自动识别WASP?

NB

也许答案就在最后控制台结果行: 您也可以该行添加到您的个人资料脚本来自动加载它。

但我没有找到如何去做。

回答

1

您应该使用您的个人资料import-module,您可以使用$profile VAR看看你的配置文件:

$profile.AllUsersAllHosts 
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 

$profile.AllUsersCurrentHost 
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1 

$profile.CurrentUserAllHosts 
C:\Users\JPB\Documents\WindowsPowerShell\profile.ps1 

$profile.CurrentUserCurrentHost 
C:\Users\JPB\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1 
1

好吧发现:

本文说明了一切:http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/04/understanding-and-using-powershell-profiles.aspx

运行此:$PROFILE | Format-List * -Force

我们得到: PS C:\用户\ royin> $简介|格式列表* -Force

AllUsersAllHosts  : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 
AllUsersCurrentHost : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1 
CurrentUserAllHosts : C:\Users\royin\Documents\WindowsPowerShell\profile.ps1 
CurrentUserCurrentHost : C:\Users\royin\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1 
Length     : 78 

所以只需添加一个名为profile.ps1图书馆^文件(选择)

而写Add-PSSnapin WASP该文件内。

相关问题