Windows 7 Resource Kit- P11

Tham khảo tài liệu 'windows 7 resource kit- p11', công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Including Functions In Windows PowerShell you could include functions from previously written scripts by dot-sourcing the script but the use of a module offers greater flexibility because of the ability to create a module manifest that specifies exactly which functions and programming elements will be imported into the current session. DIRECT FROM THE SOURCE Scopes and Dot-Sourcing James O Neill Evangelist Developer and Platform Group Windows PowerShell has three logical drives that can be thought of as holding the variables ENV which holds environment variables VARIABLE which holds Windows PowerShell variables and FUNCTION which holds Windows PowerShell functions . You can refer to the contents of an environment variable as ENV name. Windows PowerShell also has the concept of scopes which can be summarized as what happens in the script stays in the script. That is a variable alias or function that is changed in a script won t affect the Windows PowerShell environment after the script terminates. This is usually a good thing. Actions taken at the command prompt affect a global scope and scripts and functions only affect their local scope. A function that must change something in the global scope can explicitly work on Global name. However this still presents a problem for scripts that set variables we want to use later in the session or that load functions because as soon the script is completed the variables and functions are lost. Windows PowerShell allows a command to be prefixed with a dot . character. The dot operator says Run this command in the current scope and not in a scope of its own a process that is known as dot-sourcing. Using Dot-Sourcing This technique of dot-sourcing still works in Windows PowerShell and it offers the advantage of simplicity and familiarity. In the script two functions are created. The first function is called New-Line. The second function is called Get-TextStatus. The script is seen .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.