Thursday, 26 May 2011
Automate the installation of Active Directory tools with PowerShell
Get-WindowsFeature
Add-WindowsFeature RSAT-DNS-Server -restartAdd-WindowsFeature RSAT-ADDS-Tools -restart
Add-WindowsFeature RSAT-AD-AdminCenter -restart
Add-WindowsFeature RSAT-SNIS -restart
Note: These features require Windows to be restarted, so be advised that Windows may restart without prompting when passing the command to add these features in through PowerShell.
Saturday, 14 May 2011
SQL 2008 database Backup and Restore process
1.Full
2.Differential
3.Transaction Log
4.File and File group backup
Data critical situation level is high. We could use the backup pattern below:
Sun Mon Tue Web Thu Fri Sat
F D D D D D D
T T T T T T
F: weekly Sunday
D: daily Mon, Tue, Web, Thu, Fri, Sat
T: per office hour
Create a backup device
w/ management studio
Server object -> New backup device -> File -> input the name and the location of the backup file
w/ store procedure
use master
exec sp_addumpdevice 'disk', 'MYDATA', 'c:\backup\mydata.bak' //create
exec sp_dropdevice 'disk', 'c:\backup\mydata.bak' //delete
go
Create a backup task
w/ management studio
Server object -> backup database
Setting schedule backup
1.start the sql server agent
start -> all programs -> microsoft sql server 2008 -> configuration tools -> sql server configuration manager -> find 'sql server agent' service
-> start
-> properties -> start method -> automatic
2.start agent xps option
sp_configure 'show advanced options',
go
reconfigure
go
sp_configure 'Agent XPs', 1
go
reconfigure
go
3. create schedule task for automatic backup
w/ management studio
Manage -> Maintenance plan -> maintenance plan wizard -> next -> name 'weekly full', schedule 'change' -> setup the date you need to do the full backup -> choose backup method 'full' -> next -> choose the database you need to backup, check verify backup integrity -> finish.
w/ T-sql
backup database AdventureWorks
to mybackup
with stats = 20
with options
blocksize = if you need to burn the file on a CD, set to 2048, use with format
name = backup set name
description = set backup description
differential: do the differential only, if not set this parameter, full as default
format | no format: set if overwrite the existing backup
compression | no_compression: if need to compress the backup or not, not set as system default value
nounload | unload: set when backup is finished, need to unload the tape or not
restart: if there is a power failure when doing backup, set this option to restart the backup job
stats: sql server is 10% by default, view the backup process percentage frequency
Wednesday, 11 May 2011
讓 Windows 7、Vista 登入畫面不顯示帳號名稱
Thursday, 31 March 2011
Basic Windows PowerShell commands you should already know
1: Get-Help
The first PowerShell cmdlet every administrator should learn is Get-Help. You can use this command to get help with any other command. For example, if you want to know how the Get-Process command works, you can type:
Get-Help -Name Get-Process
and Windows will display the full-command syntax.
You can also use Get-Help with individual nouns and verbs. For example, to find out all the commands you can use with the Get verb, type:
Get-Help -Name Get-*
2: Set-ExecutionPolicy
Although you can create and execute PowerShell scripts, Microsoft has disabled scripting by default in an effort to prevent malicious code from executing in a PowerShell environment. You can use the Set-ExecutionPolicy command to control the level of security surrounding PowerShell scripts. Four levels of security are available to you:
- Restricted — Restricted is the default execution policy and locks PowerShell down so that commands can be entered only interactively. PowerShell scripts are not allowed to run.
- All Signed — If the execution policy is set to All Signed then scripts will be allowed to run, but only if they are signed by a trusted publisher.
- Remote Signed — If the execution policy is set to Remote Signed, any PowerShell scripts that have been locally created will be allowed to run. Scripts created remotely are allowed to run only if they are signed by a trusted publisher.
- Unrestricted — As the name implies, Unrestricted removes all restrictions from the execution policy.
You can set an execution policy by entering the Set-ExecutionPolicy command followed by the name of the policy. For example, if you wanted to allow scripts to run in an unrestricted manner you could type:
Set-ExecutionPolicy Unrestricted
3: Get-ExecutionPolicy
If you’re working on an unfamiliar server, you’ll need to know what execution policy is in use before you attempt to run a script. You can find out by using the Get-ExecutionPolicy command.
4: Get-Service
The Get-Service command provides a list of all the services that are installed on the system. If you are interested in a specific service, you can append the -Name switch and the name of the service (wildcards are permitted). When you do, Windows will show you the service’s state.
5: ConvertTo-HTML
PowerShell can provide a wealth of information about the system, but sometimes you need to do more than just view the information onscreen. Sometimes, it’s helpful to create a report you can send to someone. One way of accomplishing this is by using the ConvertTo-HTML command.
To use this command, simply pipe the output from another command into the ConvertTo-HTML command. You will have to use the -Property switch to control which output properties are included in the HTML file and you will have to provide a filename.
To see how this command might be used, think back to the previous section, where we typed Get-Service to create a list of every service that’s installed on the system. Now imagine that you want to create an HTML report that lists the name of each service along with its status (regardless of whether the service is running). To do so, you could use the following command:
Get-Service | ConvertTo-HTML -Property Name, Status > C:\services.htm
6: Export-CSV
Just as you can create an HTML report based on PowerShell data, you can also export data from PowerShell into a CSV file that you can open using Microsoft Excel. The syntax is similar to that of converting a command’s output to HTML. At a minimum, you must provide an output filename. For example, to export the list of system services to a CSV file, you could use the following command:
Get-Service | Export-CSV c:\service.csv
7: Select-Object
If you tried using the command above, you know that there were numerous properties included in the CSV file. It’s often helpful to narrow things down by including only the properties you are really interested in. This is where the Select-Object command comes into play. The Select-Object command allows you to specify specific properties for inclusion. For example, to create a CSV file containing the name of each system service and its status, you could use the following command:
Get-Service | Select-Object Name, Status | Export-CSV c:\service.csv
8: Get-EventLog
You can actually use PowerShell to parse your computer’s event logs. There are several parameters available, but you can try out the command by simply providing the -Log switch followed by the name of the log file. For example, to see the Application log, you could use the following command:
Get-EventLog -Log "Application"
Of course, you would rarely use this command in the real world. You’re more likely to use other commands to filter the output and dump it to a CSV or an HTML file.
9: Get-Process
Just as you can use the Get-Service command to display a list of all the system services, you can use the Get-Process command to display a list of all the processes that are currently running on the system.
10: Stop-Process
Sometimes, a process will freeze up. When this happens, you can use the Get-Process command to get the name or the process ID for the process that has stopped responding. You can then terminate the process by using the Stop-Process command. You can terminate a process based on its name or on its process ID. For example, you could terminate Notepad by using one of the following commands:
Stop-Process -Name notepad
Stop-Process -ID 2668
Keep in mind that the process ID may change from session to session.
Friday, 31 December 2010
Backdoor ways to reboot a Windows server
When you need to reboot a Windows server, you’ll occasionally encounter obstacles to making that happen. For instance, if remote desktop services aren’t working, how can you reboot the server? Here is a list of tricks I’ve collected over the years for rebooting or shutting down a system when I can’t simply go to the Start Menu in Windows.
- The shutdown.exe command: This gem will send a remote (or local) shutdown command to a system. Entering shutdown /r /m \\servername /f /t 10 will send a remote reboot to a system. Shutdown.exe is current on all modern Windows systems; in older versions, it was located on the Resource Kit. For more details, read this Microsoft KB article on the shutdown.exe command.
- PowerShell Restart-Computer: The equivalent of the command above in PowerShell is:
Start-Sleep 10
Restart-Computer -Force -ComputerName SERVERNAME - Hardware management device: If a device such as an HP iLO or Dell DRAC is in use, there is a virtual power button and remote screen console tool to show the system’s state regardless of the state of the operating system. If these devices are not configured with new servers, it’s a good idea to have them configured in case the mechanisms within the operating system are not available.
- Virtual machine power button: If the system in question is a virtual machine, all hypervisors have a virtual power button to reset the system. In VMware vSphere, be sure to select the option to Shut Down The Guest Operating System instead of the Power Off; this will make the call to VMware Tools to make it a clean shutdown. If that fails, the Power Off button will be the next logical step.
- Console walkthrough: In the situation where the server administrator does not have physical access to the system, walking someone through the process may be effective. For security reasons, basically a single user (domain or locally) can be created with the sole permission of rebooting the server. That person could log on as this temporary user, and then it is immediately destroyed after the local shutdown command is issued. Further, that temporary user could be created with a profile to run the reboot script on their logon to not have any interaction by the person assisting the server administrator.
- Configure a scheduled task through Group Policy: If you can’t access the system in any other mainstream way — perhaps the Windows Firewall is turned on and you can’t get in to turn it off — set a GPO to reconfigure the firewall state and slip in a reboot command in the form of the shutdown.exe command executing locally (removing the /m parameter from above). The hard part will be getting the GPO to deploy quickly.
- Enterprise system management packages: Packages such as Symantec’s Altiris and Microsoft System Center agents communicate to the management server and can receive a command to reboot the server.
- Pull the plug: This is definitely not an ideal approach, but it is effective. For physical servers, if a managed power strip with port control is available, a single system can have its power removed and restored.
What other backdoor ways have you used to reboot a Windows server? Share your comments in the discussion.
Ref: http://blogs.techrepublic.com.com/datacenter/?p=3562&tag=nl.e071
Thursday, 4 November 2010
HWM BlackBox 電腦硬體效能評比、檢測工具(繁體中文版)
HWM BlackBox是個電腦硬體資訊的檢測工具,跟之前介紹過的EVEREST、Speccy與HWiNFO32…等軟體相當類似。它可以幫我們列出電腦中的CPU、記憶體、顯示卡、主機板…等等主要硬體配備的廠牌、型號與運作效能,包括時脈、倍頻、電壓與目前溫度…等等資訊,以及各種專業玩家才會用到的詳細硬體運作數據..等等。
除此之外,HWM BlackBox還內建了一個效能評比工具,測試出來的效能評比數據還可上傳到Top10hardware網站上跟其他人比大小,包含CPU、記憶體、顯示卡、影片編碼效能、3D遊戲效能與硬碟讀寫效能…等等的綜合評分,讓我們透過更具體、更精確的數據來測試不同電腦規格、不同平台間的硬體效能好壞。
▇ 軟體小檔案 ▇ (錯誤、版本更新回報)
軟體操作介面:
第1步 將HWM BlackBox程式下載回來之後,不用安裝直接執行「BlackBox21.exe」程式即可開始使用。「處理器」頁面會列出CPU相關資訊。
第2步 這是「記憶體」相關資訊的頁面。
第3步 這是顯示卡相關資訊的頁面。
第4步 這是主機板與光碟機、硬碟機及網路卡的相關資訊。
第5步 「效能」頁面提供了一個相當簡單、實用的硬體效能評比工具,按一下「效能評估分」按鈕即可開始測試。
Tuesday, 19 October 2010
用17個防毒軟體幫檔案檢測病毒、木馬(NoVirusThanks Uploader)
跟之前介紹過的「VirusTotal Uploader」功能一樣,NoVirusThanks Uploader可以幫我們將電腦中的檔案上傳到該網站中進行線上掃毒,幫我們透過Avira、NOD32、Kaspersky、AVG、Avast…等等16個較知名的防毒軟體執行病毒檢測。
不過此軟體跟其他類似服務不同的是,除了單純的檔案上傳、掃毒功能之外,還提供了遠端檔案上傳(貼上網址轉傳過去)、開機啟動項目的檢測與刪除、展示已安裝的驅動程式清單、展示已載入的DLL程式庫...等等,每個項目都可讓我們選取後上傳,檢查看看有沒啥問題。
此外還提供了「Running Processes」電腦執行程式即時檢測視窗,我們可以像使用系統「工作管理員」那樣在視窗中看看有哪些正在運行中的檔案,如果懷疑是病毒或木馬的話,還可直接按右鍵、上傳到網站上做病毒檢測。
▇ 軟體小檔案 ▇ (錯誤、版本更新回報)
使用方法:
第1步 將軟體安裝好之後,開啟程式在「Uploader」分頁中點一下「Browse…」按鈕選取你要上傳、檢測的檔案後再按「Upload」按鈕即可開始上傳。
第2步 檢測完成後,會自動開啟一個網頁,裡面的「Status」如果顯示「CLEAN」則表示該檔案應該沒有病毒或木馬的疑慮。(當然這些檢測結果是否精準都得看個別防毒軟體的功力囉)
第3步 如果某個程式可能有問題的話,則會在「Status」中顯示「INFECTED」的紅色字體,下方的清單也會列出哪個版本的防毒軟體回報哪些病毒檢測結果,有紅字的代表可能有問題。
第4步 另外NoVirusThanks Uploader軟體中也提供了「Running Processes」功能,讓我們檢視目前運作中的程式,如果懷疑某個運作中的程式可能有問題,可以在上面按右鍵再點「Upload To Virus Scanner」。
第5步 「Registry Startups」選單裡面則列出開機後會自動啟動的項目,很多病毒或惡意程式都會在這裡登記讓電腦開機時自動執行該程式。如果你無法判別某個不知道來源的開啟啟動項目是否有問題,可以在上慢按右鍵、上傳檔案以執行病毒檢測。
第6步 「Drivers List」可以列出目前已安裝的各式驅動程式,裡外還有個「Loaded DLLs」也可檢查已載入的DLL項目。
Square Privacy Cleaner 一鍵清除:電腦操作記錄、個人隱私資料
當我們在操作電腦時都會留下一些暫存檔、快取資料與網路連線記錄、檔案開啟記錄…等等,此外在瀏覽網頁時,也會在瀏覽器中留下網址記錄、搜尋關鍵字、下載檔案記錄與Cookies、快取檔案.…等等資訊,甚至在使用軟體、應用程式時,也都會留下一些檔案清單、歷史紀錄...等資訊,如果你不希望其他人透過某些方法挖出這些跟你有關的秘密,可以試試看本文所介紹的Square Privacy Cleaner個人隱私清除程式。
Square Privacy Cleaner把常見的電腦操作痕跡、隱私資料分為「Windows General」、「Web Browsers」、「Temp Folders」、「Applications」與「Junk Files」等5個分類,我們可以依照實際需求勾選你要清除的項目,然後再按一下「Delete Traces」按鈕,即可開始搜尋、刪除你已選取的操作記錄與隱私資料,整體來說相當簡單易用。
▇ 軟體小檔案 ▇ (錯誤、版本更新回報)
使用方法:
第1步 Square Privacy Cleaner的使用方法很簡單,就是勾選你要清除的項目後再按一下「Delete Traces」按鈕即可搞定。以下簡單擷取幾張軟體操作介面,列出全部可清除的項目。
「Windows General」裡面大部分都是跟系統有關的操作記錄,很可惜此軟體目前只有英文介面,如果不太了解哪個項目是啥功能,可以用Google搜尋一下。
第2步 「Web Browsers」裡面列出了包括IE、Firefox、opera與Google Chrome等常見瀏覽器的瀏覽記錄、快取、Cookies、網址記錄與下載清單...等等。
第3步 「Temp Folders」裡面有電腦暫存資料夾裡面的一些暫時使用的檔案。
第4步 「Applications」裡面列出了大部分使用者會用到的各種知名軟體,包括WinRAR、MediaPlyaer、Foxit Reader、WinZIP、VNC、MS Office、7-zip、Java、Adobe Reader… 等,勾選並按下「Delete Traces」按鈕即可清除相關歷史紀錄與操作痕跡。
第5步 「Junk Files」就是一些電腦沒出事時用不到的log記錄檔,可依實際需求勾選、刪除。如果不是因為空間不夠或特殊隱私控管的需求,log檔留著還是有些好處,以後電腦出啥問題時,還可以挖出來檢查看看是否有啥問題。