2014-09-11 89 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該文件內。

相關問題