Tài liệu Microsoft Windows PowerShell và SQL Server 2005 SMO – Phần I ppt

11 435 0
Tài liệu Microsoft Windows PowerShell và SQL Server 2005 SMO – Phần I ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Microsoft Windows PowerShell SQL Server 2005 SMO – Phần I Như bạn có lẽ biết, Windows PowerShell tiện ích dịng lệnh ngơn ngữ kịch cung cấp mơi trường dịng lệnh cho việc khảo sát tương tác quản trị máy tính Ngồi ra, cung cấp khả viết kịch cho lệnh mà chúng tơi hoạch định chạy chúng nhiều lần Windows PowerShell phụ thuộc vào NET framework 2.0 SQL Server Management Objects, biết đến SMO, mơ hình đối tượng cho SQL Server thiết lập cấu hình Ứng dụng tảng SMO sử dụng ngơn ngữ NET Framework để lập trình chống lại mơ hình đối tượng nhớ Trong loạt này, tơi chứng minh sức mạnh Windows PowerShell phối hợp với SQL Server 2005 Cụ thể phần I này, dẫn cách thiết lập sử dụng lệnh lệnh PowerShell SMO đơn giản Giả thiết a Máy tính cài đặt NET 2.0 b Máy tính cài đặt phiên gói dịch vụ SQL Server 2005 Tải cài đặt Microsoft PowerShell a Tải file cài đặt Microsoft PowerShell “WindowsXP-KB926139-x86-ENU.exe” từ địa http://download.microsoft.com b Cài đặt PowerShell lên máy tính Bước 1: Kích đúp vào file chạy “WindowsXP-KB926139-x86-ENU.exe” [Hình 1.0] Hình Bước 2: Kích “Run” [Hình 1.1] Hình Bước 3: Kích “Next” [Hình 1.2] Hình Bước 4: Chọn tùy chọn “I agree” [Hình 1.3] Hình Bước 5: Chờ trình cài đặt [Hình 1.4] Hình Bước 6: Kích Finish [Hình 1.5] Hình Chạy PowerShell Có số cách để chạy PowerShell Một phương pháp tìm tới dấu nhắc lệnh nhập lệnh PowerShell [Hình 1.6] PowerShell Hình Lệnh PowerShell xuất [Hình 1.7] Hình Cách khác, bạn chạy PowerShell cách chọn Programs-Windows PowerShell 1.0Windows PowerShell [Hình 1.8] Hình Lệnh Help Trong cửa sổ PowerShell, bạn truy cập vào danh sách lệnh cách nhập lệnh Get-command Lệnh hiển thị tồn lệnh có sẵn PowerShell [Hình 1.9] Add-Content Add-History Add-Member Add-PSSnapin Clear-Content Clear-Item New-Alias New-Item New-ItemProperty New-Object New-PSDrive New-Service Clear-ItemProperty Clear-Variable Compare-Object ConvertFromSecureString Convert-Path ConvertTo-Html ConvertToSecureString Copy-Item Copy-ItemProperty Export-Alias Export-Clixml Export-Console Export-Csv ForEach-Object Format-Custom Format-List Format-Table Format-Wide Get-Acl Get-Alias GetAuthenticodeSignature Get-ChildItem Get-Command Get-Content Get-Credential Get-Culture Get-Date Get-EventLog Get-ExecutionPolicy Get-Help Get-History Get-Host Get-Item Get-ItemProperty Get-Location Get-Member Get-PfxCertificate Get-Process Get-PSDrive Get-PSProvider Get-PSSnapin Get-Service Get-TraceSource New-TimeSpan New-Variable Out-Default Out-File Out-Host Out-Null Out-Printer Out-String Pop-Location Push-Location Read-Host Remove-Item Remove-ItemProperty Remove-PSDrive Remove-PSSnapin Remove-Variable Rename-Item Rename-ItemProperty Resolve-Path Restart-Service Resume-Service Select-Object Select-String Set-Acl Set-Alias SetAuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item Set-ItemProperty Set-Location Set-PSDebug Set-Service Set-TraceSource Set-Variable Sort-Object Split-Path Start-Service Start-Sleep Start-Transcript Stop-Process Stop-Service Stop-Transcript Suspend-Service Get-UICulture Get-Unique Get-Variable Get-WmiObject Group-Object Import-Alias Import-Clixml Import-Csv Invoke-Expression Invoke-History Invoke-Item Join-Path Measure-Command Measure-Object Move-Item Move-ItemProperty Tee-Object Test-Path Trace-Command Update-FormatData Update-TypeData Where-Object Write-Debug Write-Error Write-Host Write-Output Write-Progress Write-Verbose Write-Warning Hình 10 Một SMO đơn giản PowerShell Hãy truy vấn sys.sydatabases SQL Server trường hợp “SQLEXPRESS” từ máy chủ “HOME” sử dụng PowerShell SMO Bước 1: Vào cửa sổ lệnh: Start – run – cmd Bước 2: Bắt đầu PowerShell cách nhập lệnh PowerShell Bước 3: Thực lệnh, bước một, sau [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") $Server = new-object ("Microsoft.SqlServer.Management.Smo.Server") "HOME\SQLEXPRESS" foreach($database in $Server.databases) {$database.name} Bạn thu kết hình [Hình 2.0] Hình 11 Các thành phần SMO Để hiển thị tất thành phần liên quan đến đối tượng $Server, thực lệnh Bước 1: Vào cửa sổ lệnh: Start – run – cmd Bước 2: Bắt đầu PowerShell cách nhập lệnh PowerShell Bước 3: Thực lệnh, bước một, sau [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") $Server = new-object ("Microsoft.SqlServer.Management.Smo.Server") "HOME\SQLEXPRESS" $server | get-member Bạn thu kết hình [Hình 2.1] Alter AttachDatabase CompareUrn DeleteBackupHistory Deny DetachDatabase DetachedDatabaseInfo get_State get_SystemDataTypes get_SystemMessages get_Triggers get_Urn get_UserData get_UserDefinedMessages EnumAvailableMedia EnumCollations EnumDatabaseMirrorWitnessRoles EnumDetachedDatabaseFiles EnumDetachedLogFiles EnumDirectories EnumErrorLogs EnumLocks EnumMembers EnumObjectPermissions EnumPerformanceCounters EnumProcesses EnumServerAttributes EnumServerPermissions EnumStartupProcedures EnumWindowsDomainGroups EnumWindowsGroupInfo EnumWindowsUserInfo Equals GetActiveDBConnectionCount GetDefaultInitFields GetHashCode GetPropertyNames GetSmoObject GetType get_ActiveDirectory get_BackupDevices get_Configuration get_ConnectionContext get_Credentials get_Databases get_DefaultTextMode get_Endpoints get_Events get_FullTextService get_Information get_InstanceName get_JobServer get_Languages get_LinkedServers get_Logins get_Mail get_Name get_NotificationServices get_Properties get_ProxyAccount get_UserOptions Grant Initialize IsDetachedPrimaryFile IsWindowsGroupMember KillAllProcesses KillDatabase KillProcess PingSqlServerVersion ReadErrorLog Refresh Revoke SetDefaultInitFields set_DefaultTextMode set_UserData ToString ActiveDirectory BackupDevices Configuration ConnectionContext Credentials Databases DefaultTextMode Endpoints Events FullTextService Information InstanceName JobServer Languages LinkedServers Logins Mail Name NotificationServices Properties ProxyAccount ReplicationServer Roles ServiceMasterKey Settings State SystemDataTypes SystemMessages Triggers Urn get_ReplicationServer get_Roles get_ServiceMasterKey get_Settings UserData UserDefinedMessages UserOptions Hình 12 Kết luận Như giải thích từ đầu viết, loạt minh họa sức mạnh Windows PowerShell phối hợp với SQL Server 2005 Trong loạt này, chứng minh sức mạnh Windows PowerShell phối hợp với SQL Server 2005 Phần I loạt dẫn cách thiết lập sử dụng lệnh PowerShell SMO đơn giản   ... EnumServerAttributes EnumServerPermissions EnumStartupProcedures EnumWindowsDomainGroups EnumWindowsGroupInfo EnumWindowsUserInfo Equals GetActiveDBConnectionCount GetDefaultInitFields GetHashCode... get_Information get_InstanceName get_JobServer get_Languages get_LinkedServers get_Logins get_Mail get_Name get_NotificationServices get_Properties get_ProxyAccount get_UserOptions Grant Initialize... bước một, sau [reflection.assembly]::LoadWithPartialName( "Microsoft. SqlServer .Smo" ) $Server = new-object ( "Microsoft. SqlServer.Management .Smo .Server" ) "HOME\SQLEXPRESS" $server | get-member Bạn

Ngày đăng: 22/12/2013, 22:16

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan