TAILIEUCHUNG - Microsoft SQL Server 2008 R2 Unleashed- P56

Microsoft SQL Server 2008 R2 Unleashed- P56:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 494 CHAPTER 17 Administering SQL Server 2008 with PowerShell Passing Arguments PowerShell has a special reserved variable named args. It can be used with scripts and functions and represents any arguments passed to the script or function when it is invoked as shown here PS add-content c temp PS add-content c temp args 0 PS c temp 1 2 3 3 1 PS In the preceding example a two-line script is created and then it is invoked while passing some arguments to it. displays the number of arguments passed to the script whereas args 0 displays the value of the first argument only. Later an example of a PowerShell script that can do a database backup is provided. The example is extended to show how a script could be used to accept an argument that would be the name of the database the script will back up. Using Param A special construct param can be used to force the way arguments are passed to a script or function PS function test_param param string arg1 write-host Argument 1 is arg1 PS test_param testing Argument 1 is testing PS test_param -arg1 testing Argument 1 is testing PS In this example param is used to specify that a parameter passed to this script will be a string object and will be contained in the variable arg1 for later use in the script. NOTE The biggest difference between using param or args with arguments occurs when the number of arguments is known versus unknown. The param keyword should not be used when the number of arguments passed is not known. Download from PowerShell Scripting Basics 495 NOTE string i s a shortcut in PowerShell where you specify that the argument as in the preceding example will be a string and not something else such as a number or integer. A dozen or so of these shortcuts are available in PowerShell and they are typically known as type accelerators. Arrays To PowerShell arrays are simply a listing of data. They can be used for various tasks and can be .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.