來任務(wù)了,由于要Windows服務(wù)器版本要升級(jí):2008 -> 2016,所以要做很多的準(zhǔn)備工作,比如OU, GPO。由于OU劃分很細(xì),有幾百個(gè)OU,要在2016OU下面新建所有在2008OU下已經(jīng)存在的OU。那就用PowerShell來搞搞吧!但是找了一臺(tái)2008的server,運(yùn)行一下Get-ADOrganizationalUnit這個(gè)PowerShell的命令,我去,竟然提示我不是有效的命令,錯(cuò)誤詳細(xì)信息見下:

奇怪了,之前在另外一臺(tái)server上面還是可以用的,剛開始懷疑是不是PowerShell版本太低了,索性查一下:
PS C:\Users\admin> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.2515
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2515
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1版本都5.1了,不是很老啊!OK,那再來看看有沒有AD模塊吧,畢竟這個(gè)命令是對(duì)AD的操作。運(yùn)行: get-module -listavailable 回車,走你,結(jié)果一看。原來如此,目測(cè)沒有AD模塊。

那就導(dǎo)入一下吧,運(yùn)行:
PS C:\Windows\system32> Add-WindowsFeature RSAT-AD-PowerShell
然后再運(yùn)行一把get-module,看一下,ActiveDirectory加載過來了
PS C:\Windows\system32> get-module -listavailableRSAT = Remote Server Administrator Tools

最后運(yùn)行一下命令:PS C:\Windows\system32> Get-ADOrganizationalUnit,不再報(bào)錯(cuò),而且提示需要參數(shù),著就對(duì)了。
我在另外一個(gè)server上面也試了另外一種方法:
首先運(yùn)行:get-module -listavailable 查看ActiveDirectory模塊是否已經(jīng)加載。
然后就是直接運(yùn)行:import-module activedirectory
如果沒有報(bào)錯(cuò),就再運(yùn)行:get-module -listavailable
這個(gè)時(shí)候ActiveDirectory模塊就被導(dǎo)入了,關(guān)于AD相關(guān)的PowerShell命令你就可以開始用了。
The term 'Get-ADOrganizationalUnit' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:5 char:38
+ $SVSOUList = Get-ADOrganizationalUnit <<<< -SearchBase $sourceOU -Filter {Name -like "W2K8_*"} |select -ExpandProperty Name
+ CategoryInfo : ObjectNotFound: (Get-ADOrganizationalUnit:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\admin> import-module activedirectory
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
PS C:\Users\admin> get-module -listavailable
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest ActiveDirectory {}
Manifest ADRMS {}
Manifest AppLocker {}
Manifest BestPractices {}
Manifest BitsTransfer {}
Manifest GroupPolicy {}
Manifest PSDiagnostics {}
Manifest ServerManager {}
Manifest TroubleshootingPack {}
Manifest Citrix.XenDesktop.Admin {}
Manifest Citrix.Common.Commands {}
Binary TelemetryModule {}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前名稱:PowerShell提示輸入命令不是有效命令-創(chuàng)新互聯(lián)
路徑分享:http://chinadenli.net/article6/ejsig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、品牌網(wǎng)站制作、用戶體驗(yàn)、營(yíng)銷型網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)公司、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容