顯示具有 Windows Server 標籤的文章。 顯示所有文章
顯示具有 Windows Server 標籤的文章。 顯示所有文章

2011年9月12日 星期一

「sudo」 for Windows PowerShell

相信有許多 Unix-like 的愛用者,
對於 sudo 帶來的便利性及安全性,
都有很高的依賴性及倚靠性,
在 Windows 的世界,雖然有個「以系統管理員身分執行」的玩意兒,
但是在習慣使用文字介面如 cmd, vim, PowerShell 的人們來說,
倘若遇到需要系統管理員權限的設定檔或文字檔,
往往就是一句「XXX」之後,還要到開始功能表尋找到 cmd 或 PowerShell,
然後再用滑鼠點右鍵選擇「以系統管理員身分執行」,然後再 cd 到剛剛的資料夾,再用編輯器開啟、編輯、blah blah....

一來一往,往往費神又費時,
今天介紹在 PowerShell 使用時,
可以輸入 Unix-like 中的 sudo (或使用者自己取)
後面再帶 vim 或 notepad 指令,接著被修改的設定檔或文字檔,
便可以系統管理員權限開啟該設定檔或文字檔,以便進行編修!

一、首先「以系統管理員身分執行」開啟 PowerShell,
預設沒錯的話,您會在您的家目錄,如:C:\Users\XXXXXXX

二、輸入指令以便新增 scripts 資料夾:

New-Item -ItemType directory $HOME\Documents\Scripts


三、使用編輯器如 vim 或 notepad 開啟 PowerShell 之 Profile 檔:
(預設為 WindowsPowerShell\Microsoft.PowerShell_profile.ps1)

notepad.exe $PROFILE

四、新增如下文字於該檔中:

New-PSDrive -name script -PSProvider FileSystem -Root $HOME\Documents\Scripts


五、存檔並離開。

六、重啟你的 PowerShell ,你將發現上面所新增的資料夾被 mount 起來,可以繼續進行:

cd script:


七、進入 script 槽後,用慣用的編輯器開啟新增 sudo.ps1 script檔:

notepad.exe sudo.ps1


八、加入 sudo script 如下:

param(
        [switch]$ps,            # Switch for running args as powershell script
        [string]$file,             # Script/Program to run
        [string]$arguments = $args # Arguments to program/script
     )

# Find our powershell full path
$powershell = (get-command powershell).definition

# Get current directory
$dir = get-location

#If we're running this as a elevated powershell script
if ($ps){

        # Script verification
        if([System.IO.File]::Exists("$(get-location)\$file")) {

                # Set the $script to full path of the ps script
                $script = (get-childitem $file).fullname
        }

        # Create a powershell process
        $psi = new-object System.Diagnostics.ProcessStartInfo $powershell

        $psi.WorkingDirectory = Get-Location

        # Combine the script and its arguments
        $sArgs = $script + " " + $arguments

        # Set the arguments to be the ps script and it's arguments
        $psi.Arguments = "-noexit -command set-location $dir; $sArgs"

        # Magic to run as elevated
        $psi.Verb = "runas";
}

# We're running something other than a powershells script
else {

        # File verification
        if([System.IO.File]::Exists("$(get-location)\$file")) {

                # Get full path
                $file = (get-childitem $file).fullname
        }

        # Same as above, create proccess/working directory/arguments/runas
        $psi = new-object System.Diagnostics.ProcessStartInfo $file
        $psi.Arguments = $arguments
        $psi.Verb = "runas"
}

# Start the process
[System.Diagnostics.Process]::Start($psi)


九、存檔並離開!

十、再次開啟 PowerShell 的 Profile 設定檔:

notepad.exe $PROFILE


十一、新增關聯指令:

New-Alias -Name sudo 'script:\sudo.ps1'

注意這裡的紅色字 sudo 可以改成任何你想要的字,只要不跟內建指令撞名即可!

十二、重啟 PowerShell,你可以使用:

sudo notepad C:\Windows\System32\drivers\etc\hosts



sudo vim $PROFILE

就會以系統管理員權限開啟,當然 Windows 的 UAC 會開啟並問你是或否,此時按「是」,
便會開啟具有系統管理員權限的視窗了!

Reference To: http://techha.us/2010/05/sudo-for-powershell/
                      http://www.ainotenshi.org/710/%E2%80%98sudo%E2%80%99-for-powershell-sorta

2011年8月10日 星期三

下載:Windows Server 2008 試用版

[HTTP]下載Windows Server 2008 試用版+語言套件(Microsoft載點[高速{avg.800kb/s}])

下載Windows Server 2008 試用版
當然可以crack LA xD
概覽(翻譯)
這個軟件的評價和測試目的。評價的Windows Server ® 2008軟件不要求產品激活或進入一個產品密鑰。任何版本的Windows Server 2008的可能是安裝激活和評價 , 最初60天。
如果您需要更多時間來評估Windows Server 2008的, 60天的試用期可能會重置(或重新武裝)的3倍,擴大了原來的60天評估期達180天 , 總有可能評估時間為240天。過了這段時間,您需要卸載該軟件 , 或升級到完全授權版本的Windows Server 2008 。
Overview
This software is for evaluation and testing purposes. Evaluating Windows Server® 2008 software does not require product activation or entering a product key. Any edition of Windows Server 2008 may be installed without activation and evaluated for an initial 60 days.

If you need more time to evaluate Windows Server 2008, the 60 day evaluation period may be reset (or re-armed) three times, extending the original 60 day evaluation period by up to 180 days for a total possible evaluation time of 240 days. After this time, you will need to uninstall the software or upgrade to a fully-licensed version of Windows Server 2008.

x86
x64

下載Windows Server 2008 語言套件
概觀
多語系使用者介面 (MUI) 語言套件 (Windows Server® 語言套件),可以在 Windows Server® 2008 的環境中啟用多語系使用者介面。在 Windows Server® 2008 影像新增一個或一個以上的語言套件,便能於安裝的 Windows Server® 作業系統中啟用一個或一個以上的語言,讓公司能在世界各地部署相同的 Windows Server® 2008 影像,且仍能提供本地化的使用者介面。
32 位元 (x86) 語言套件
說明
每一個語言套件皆為一支 .cab 檔案。語言套件的 .cab 檔案會分組為 .img 影像下載檔案。以下是 .img 影像下載檔案的內容:

32 位元 (x86) 語言套件

• 群組 1 (英文、德文、日文、法文、西班牙文)

      o 檔案名稱:6001.18000.080118-1840_x86fre_Server_LP_1-KRMSLP1_DVD.img

• 群組 2 (簡體中文、繁體中文、韓文、葡萄牙文 (巴西))

      o 檔案名稱:6001.18000.080118-1840_x86fre_Server_LP_2-KRMSLP2_DVD.img

• 群組 3 (義大利文、俄文、葡萄牙文 (葡萄牙)、荷蘭文、瑞典文)

      o 檔案名稱:6001.18000.080118-1840_x86fre_Server_LP_4-KRMSLP4_DVD.img

• 群組 4 (波蘭文、土耳其文、捷克文、匈牙利文)

      o 檔案名稱:6001.18000.080118-1840_x86fre_Server_LP_5-KRMSLP5_DVD.img

• 群組 5 (阿拉伯文、丹麥文、挪威文、芬蘭文、希伯來文、希臘文、泰文、烏克蘭文、羅馬尼亞文、斯洛伐克文、斯洛維尼亞文、克羅埃西亞文、塞爾維亞拉丁文、保加利亞文、立陶宛文、拉脫維亞文、愛沙尼亞文)

      o 檔案名稱:6001.18000.080118-1840_x86fre_Server_LP_6-KRMSLP6_DVD.img



amd64 (x64) 語言套件

• 群組 1 (英文、德文、日文、法文、西班牙文)

      o 檔案名稱:6001.18000.080118-1840_amd64fre_Server_LP_1-KRMSLPX1_DVD.img

• 群組 2 (簡體中文、繁體中文、韓文、葡萄牙文 (巴西))

      o 檔案名稱:6001.18000.080118-1840_amd64fre_Server_LP_2-KRMSLPX2_DVD.img

• 群組 3 (義大利文、俄文、葡萄牙文 (葡萄牙)、荷蘭文、瑞典文)

      o 檔案名稱:6001.18000.080118-1840_amd64fre_Server_LP_4-KRMSLPX4_DVD.img

• 群組 4 (波蘭文、土耳其文、捷克文、匈牙利文)

      o 檔案名稱:6001.18000.080118-1840_amd64fre_Server_LP_5-KRMSLPX5_DVD.img

• 群組 5 (阿拉伯文、丹麥文、挪威文、芬蘭文、希伯來文、希臘文、泰文、烏克蘭文、羅馬尼亞文、斯洛伐克文、斯洛維尼亞文、克羅埃西亞文、塞爾維亞拉丁文、保加利亞文、立陶宛文、拉脫維亞文、愛沙尼亞文)

      o 檔案名稱:6001.18000.080118-1840_amd64fre_Server_LP_6-KRMSLPX6_DVD.img



Itanium (x64) 語言套件

• 群組 1 (英文、德文、日文、法文)

      o 檔案名稱:60016001.18000.080118-1840_ia64fre_Server_LP_1-KRMIALPI1_DVD.img

• 群組 2 (簡體中文、韓文)

      o 檔案名稱:6001.18000.080118-1840_ia64fre_Server_LP_2-KRMIALPI2_DVD.img



下載項目中的檔案下列連結可以連至本下載項目中的個別檔案。下載最適合您的檔案。
6001.18000.080118-1840_amd64fre_Server_LP_1-KRMSLPX1_DVD.img
362.1 MB
下載

6001.18000.080118-1840_amd64fre_Server_LP_2-KRMSLPX2_DVD.img
310.8 MB
下載

6001.18000.080118-1840_amd64fre_Server_LP_4-KRMSLPX4_DVD.img
320.8 MB
下載

6001.18000.080118-1840_amd64fre_server_lp_5-krmslpx5_dvd.img
257.8 MB
下載

6001.18000.080118-1840_amd64fre_Server_LP_6-KRMSLPX6_DVD.img
1018.7 MB
下載

6001.18000.080118-1840_ia64fre_Server_LP_1-KRMIALPI1_DVD.img
283.8 MB
下載

6001.18000.080118-1840_ia64fre_Server_LP_2-KRMIALPI2_DVD.img
172.0 MB
下載

6001.18000.080118-1840_x86fre_Server_LP_1-KRMSLP1_DVD.img
325.1 MB
下載

6001.18000.080118-1840_x86fre_Server_LP_2-KRMSLP2_DVD.img
278.3 MB
下載

6001.18000.080118-1840_x86fre_Server_LP_4-KRMSLP4_DVD.img
280.6 MB
下載

6001.18000.080118-1840_x86fre_Server_LP_5-KRMSLP5_DVD.img
225.7 MB
下載

6001.18000.080118-1840_x86fre_Server_LP_6-KRMSLP6_DVD.img
905.6 MB
下載

Power shell 執行 ps1檔時 出現檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱 "get-help about_signing"


Power shell 的console模式 執行 ps1檔時出現: 檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱 "get-help about_signing"。
在PowerShell console模式下執行 Set-ExecutionPolicy RemoteSigned
如 :
PS C:\> Set-ExecutionPolicy RemoteSigned
PowerShell console模式下執行.ps1程式:
PS C:\Powertools> .\Test.ps1
Dos command下執行Powershell的ps1程式:
powershell c:\Powertools\Test.ps1

下載:微軟Windows命令行PowerShell 2.0


微軟Windows命令行工具PowerShell 2.0是否可以下載了呢?這讓很多開發和管理人員感到困惑。微軟日前在官方博客中證實,Windows客戶端和服務器各版本都已經可以下載使用 PowerShell 2.0。

PowerShell 2.0預設包含在Windows 7和Windows Server 2008 R2中, 舊版Windows其實在很久之前也可以下載使用PowerShell了,包括簡體中文和繁體中文。之所以造成一些混淆是因為微軟不再單 獨提供PowerShell 2.0,而是將其整合到了Windows管理架構(Management Framework)中

微軟工程師Jeffrey Snover表示:「這一混淆是我們造成的,因為它的重新發佈不再稱為PowerShell 2.0,而是Windows管理架構。除了PowerShell 2.0之外,Windows管理架構還包括另外兩個技術,名為Windows遠程管理WinRM 2.0和後台智能傳輸服務(BITS)4.0。」

下載Windows管理架構核心(WinRM 2.0和Windows PowerShell 2.0):
Windows Server 2008:
http://www.microsoft.com/downloads/details.aspx?FamilyId=863e7d01-fb1b-4d3e-b07d-766a0a2def0b
64位Windows Server 2008:
http://www.microsoft.com/downloads/details.aspx?FamilyId=d37e25cf-db05-4b23-a852-cdf865d81b82
Windows Server 2003:
http://www.microsoft.com/downloads/details.aspx?FamilyId=909bbcf1-bd78-4e03-8c83-69434717e551
Vista:
http://www.microsoft.com/downloads/details.aspx?FamilyId=f2fa1227-9a34-4e29-aa03-62f5c00e16f2
64位Vista:
http://www.microsoft.com/downloads/details.aspx?FamilyId=0f73efa2-f8d6-45f3-a8f8-5cdc205b119a
XP和Windows Embedded:
http://www.microsoft.com/downloads/details.aspx?FamilyId=60cb5b6c-6532-45e0-ab0f-a94ae9ababf5
http://news.mydrivers.com/1/164/164503.htm