New-PSDrive -PSProvider sqlserver -root “SQLSERVER:\SQL\sapien01,1451\default” -name MyWindowsSQL -Credential $mycred # – Creating SQLSERVER: connection to Windows SQLServer: $MyUserName = ‘sa’ $MyPassword = ConvertTo-SecureString ‘$SqlPwd01!’ -asplaintext -force # – New way for Streamlining Get-Credential: In order to use the drive, it need to be recreated with the proper credentials for cross-platform use.īelow steps will create additional SQLServer: drives to another SQLServer on the *network. This will allow you to navigate thru the SQL Engine like a file system from the console prompt. If ($PSversionTable.PSEdition -eq "Desktop") ).countĪlthough, I’m not a fan of using SQLServer: drive. # – Use Set-StrictMode for debug purpose: # – Logic Structure for executing either PowerShell Version: In it’s basic code form, could look be something like this: So, why not start working towards, what I call, “Hybrid-scripting”? Powershell Core provides the necessary elements to help with cross-platform scripting. You are still using PowerShell, and Windows PowerShell is not going to be dropped nor removed any time soon. We all know the next generation (or evolution) of PowerShell is PowerShell Core. Use both!įollowing my recent post on “ PSCore6 – SQLServer Module Expanding The Barrier Cross-Platform“, here’s a sample Hybrid-Script for cross-platform use. Just think about supporting a cross-platform environment. There’s some discussion around scripting on using Windows PowerShell vs PowerShell Core.
0 Comments
Leave a Reply. |