TAILIEUCHUNG - Hướng dẫn học Microsoft SQL Server 2008 part 18

Các biến cũng có thể chứa các đối tượng hoặc các bộ sưu tập. Bộ sưu tập là chỉ là một nhóm đối tượng, chẳng hạn như một mảng. Thật dễ dàng để tạo ra một bộ sưu tập chỉ bằng cách chỉ định một danh sách các giá trị cho một biến, như thế này: PS $ thứ = 1,2,4,6,8 | Part I Laying the Foundation However a string object variable with the value of 7 can be created as follows PS string counter 7 Variables can also contain objects or collections. Collections are just a group of objects such as an array. It s easy to create a collection just by assigning a list of values to a variable like this PS stuff 1 2 4 6 8 The list of numbers is grouped into a collection of integer objects and placed in the variable stuff. Individual elements within the collection can be accessed by using their ordinal number PS stuff 2 4 PS Addressing individual elements of an array is nice but the power of collections is realized by being able to iterate through the members of the collection. PowerShell offers two versions of foreach logic the first being a cmdlet to which a collection is piped like this PS stuff foreach-object write-output _ 1 2 4 6 8 Notice the variable _ which is defined as the current object in the set of objects the cmdlet is iterating through. The other version is the foreach language element which enables naming of the member PS foreach thing in stuff write-output thing 1 2 4 6 8 Now within the script block operating on the members of the collection conditions can be checked. For example if the script should only operate on elements with a value not greater than 4 the script would read as follows PS stuff foreach-object if _ -gt 4 break else write-output _ 1 2 4 Table 7-1 shows most of the comparison operators within PowerShell. 132 Scripting with PowerShell 7 TABLE 7-1 Operator -It Comparison Operators Description less than -le less than or equal to -gt greater than -ge greater than or equal to -eq equal to -ne not equal to -like like wildcard pattern matching Suppose you have a text file called that contains a list of servers one server name per line. The file might resemble something like this SQLTBWS SQLTBXP SQLTBW7 SQLPROD1 SQLPROD2 By using the Get-Content cmdlet this list of servers can easily

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.