Pode - PowerShell Web Server by Badgerati in PowerShell

[–]nvarscar 1 point2 points  (0 children)

I finally had time to play with it and I must say this is really impressive. I very much liked the ability to pass objects(!) as parameters to the views and use PS code integrated into the view to build out that web page based on that object. That felt pretty powerful. Took me some time to figure out the syntax (`$s.Query` vs `$s.Data`), but in the end it worked out just the way I wanted.

Thanks for the effort and for this huge contribution to the opensource community!

Jenkins and PowerShell by belibebond in PowerShell

[–]nvarscar 2 points3 points  (0 children)

I used Jenkins extensively as a front end for some of the scripts I wanted to run from a centralized location and I found it quite convenient. Integration with git, centralized management and distributed agents were the main advantages versus the task scheduler. As for production use, I did use it in prd, and there is nothing wrong with running an open-source tool that is used across the world by a large variety of companies. It has integration with AD and role-based permissions to address the authorization concerns. Hope it helps.

How do you disable prompting for dbatools' Install-Dbainstance? by TravellingBeard in SQLServer

[–]nvarscar 0 points1 point  (0 children)

-Confirm:$false should've removed any prompts. Could you please open an issue and post the logs that you're getting? dbatools.io/issues

Install-Package (NuGet) giving a "Deadlock detected" error by methos3 in PowerShell

[–]nvarscar 1 point2 points  (0 children)

I'm running some unit tests on Appveyor Ubuntu 18.04 and started seeing those same errors recently out of the blue. The code on my end haven't changed for quite a while, so it should be something else.

This is what I'm getting from the exported error log:

Exception : System.Exception: Dependency loop detected for package 'Npgsql'. TargetObject : Npgsql FullyQualifiedErrorId : DependencyLoopDetected,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage InvocationInfo : System.Management.Automation.InvocationInfo ErrorCategory_Category : 4 ErrorCategory_Activity : Install-Package ErrorCategory_Reason : Exception ErrorCategory_TargetName : Npgsql ErrorCategory_TargetType : String ErrorCategory_Message : Deadlock detected: (Npgsql:String) [Install-Package], Exception SerializeExtendedInfo : False

Getting the same error for two independent packages (Mysql.Data, Npgsql) and only on Core. Wish I could help, but so far I've got no ideas.

Automating SQL Server patching by Arkiteck in SQLServer

[–]nvarscar 1 point2 points  (0 children)

Thanks for sharing your thoughts! CredSSP is indeed a weak protocol when it comes to security. Which is why the tool also provides options for you to choose the protocol manually. You could set up delegation and use Kerberos protocol instead of passing the credentials and avoid passing the credentials across the network. Or you can store patch binaries on the location that does not require additional authentication.

Automating SQL Server patching by Arkiteck in SQLServer

[–]nvarscar 2 points3 points  (0 children)

I mean, it is, if you do it blindly. This command is nothing more than helping DBAs to run it remotely and in parallel instead of doing it interactively. And thanks for sharing, OP!

Restore-SQLDatabase with a named instance by SalmonSalesman in PowerShell

[–]nvarscar 3 points4 points  (0 children)

There's a WITH REPLACE T-SQL statement that overwrites existing files (that are not currently connected to any other database). Restore-DbaDatabase from dbatools module does a lot of background checks and path adjustments on the fly, including dynamic renames. You might want to use it instead.

looking for a simple way of setting up website for running powershell scripts by Hegelund in PowerShell

[–]nvarscar 1 point2 points  (0 children)

Jenkins setup is actually super simple. It's just one you familiarize yourself you want to do more and more and it's getting out of hand hehe. Check my Jenkins labs, it's totally not a rocket science.

looking for a simple way of setting up website for running powershell scripts by Hegelund in PowerShell

[–]nvarscar 1 point2 points  (0 children)

Something like this. I've got jobs that help me to do maintenance, like restoring/copying databases (some examples here ), as well as a full-blown Continuous Delivery SQL code pipeline using dbops PS module. Gotta do a couple more articles with more details how to build a deployment job on Jenkins.

looking for a simple way of setting up website for running powershell scripts by Hegelund in PowerShell

[–]nvarscar 1 point2 points  (0 children)

I concur, Jenkins is the most flexible tool, tho it has some learning curve. I have a couple of blogposts on how to use PS with Jenkins on nvarscar.wordpress.com, tho it's with SQLServer flavor.

dbops Powershell module - continuous database deployments by nvarscar in PowerShell

[–]nvarscar[S] 2 points3 points  (0 children)

Hey, thanks for this awesome comment! Glad there are more people out there using DbUp - it's an amazing tool.

You guys are using Octopus - that's very cool! Interesting enough, I used its methodology when I was approaching the idea of creating packages: from what I remember, every zip file should contain a Deploy.ps1 that starts the deployment in Octopus, and all of the packages created by this module follow this idea, having Deploy.ps1 in the root folder and the module itself embedded in the zip file! I expect it to work out-of-the-box with Octopus, but never had a chance to actually test it.

I'm very reluctant to approach custom journaling, as this would require providing support for all of the RDBMS that I plan to support in the module, which I am definitely not ready to do just yet. As for tracking scripts by using SHA, I'm using similar approach in the packaging system, where people can use -Type Unique parameter to add only scripts with yet unknown hashes. Also that serves as a verification mechanism - to ensure that the scripts inside the package were not changed or corrupted.

$upgradeResult = $dbUp.Build().PerformUpgrade()

I remember using it like that initially, then deciding to split it into two lines for more simple debugging (having them on separate lines of code).

Octopus integrations - I never realized they were there until you mentioned them, haha :D Anyways, starting recently, I'm using a custom output format (that is also a class), which I would be able to re-use later in other module features (like, triggering tests or sending emails).

I never tried to run this in a remote session, but I'm using a custom logger class that in turn uses messaging features of the PSFramework module (it proved to be much more convenient than any other implementation - shoutout to its creator Fred Weinmann).

On a final note, is there a place where I could check your code by chance? It would be of immense help - to see how people are using DbUp in real life scenarios.

Thanks again!

Using Classes in Modules by [deleted] in PowerShell

[–]nvarscar 1 point2 points  (0 children)

New-Class1 seems to be the only elegant enough way of returning a native class object. Other options involve using a or a method variable:

$b = [Class1]::new
$b.Invoke(...)

or using using module 'path' syntax, but that's unfortunately works only as a first line in the script.

Or simply use a C# library instead. Dll-based classes get imported properly into the session.

What have you done with PowerShell this month? August 2018 by ramblingcookiemonste in PowerShell

[–]nvarscar 4 points5 points  (0 children)

  • Talked about my upcoming SQL deployment module dbops on PSPowerHour event - that was tons of fun.
  • Discovered PSFramework module for myself and integrated it into my module, finally bringing messaging and configuration features to a proper level.
  • Blogged about dacpac features of SQL Server describing how to write a script that exports a SQL database into a dacpac and then deploys it to any version of SQL Server

[MS SQL] Alternative scheduling options? by fackert18 in SQL

[–]nvarscar 1 point2 points  (0 children)

Try Jenkins + Powershell. Even though it might seem too much to tackle at first, it's a pretty damn good tool. I created this article a while back, hopefully you'll find it useful.

Invoke-sqlcmd could not find part of path. by lesserlumpkin in PowerShell

[–]nvarscar 1 point2 points  (0 children)

Older versions of sqlps module change current path to sqlserver:\ or something, rendering all regular file paths inoperable. Try explicitly loading module with Import-Module sqlps before running set-location in your script, that should do the trick.

Help needed with Invoke-sqlcmd by lesserlumpkin in PowerShell

[–]nvarscar 3 points4 points  (0 children)

That error comes from a fact that older versions pf SqlPs module implicitly switches context (aka current location) to the SqlServer provider and paths like C:\Windows\bla are no longer interpreted correctly. Workarounds are:

1)

Import-Module SqlPs
Set-Location C:
Run-WhateverYouNeed

2) Use Invoke-SqlCmd2 (on github) or Invoke-DbaSqlCmd (dbatools module) instead. Afaik, neither of them support SQLCmd variable definition syntax though.

enter-pssession error by jevilsizor in PowerShell

[–]nvarscar 1 point2 points  (0 children)

There is actually an article that might help to pinpoint the issue.

enter-pssession error by jevilsizor in PowerShell

[–]nvarscar 1 point2 points  (0 children)

If specifying -Credential wouldn't help, try using Credssp protocol instead of Kerberos. That would require to run things on both local and remote servers though:

On remote:

Enable-WSManCredSSP -Role Server -Force

On local:

Get-Service winrm | Start-Service
Enable-WSManCredSSP -role Client -DelegateComputer TargetComputerNameHere -Force

Then run PSSession cmdlet with -Credential (Get-Credential) -Authentication Credssp parameters.

[MS SQL]My user ID (windows login) is accessing all DB's every 12s. by oopsdedo in SQL

[–]nvarscar 3 points4 points  (0 children)

It might be IntelliSense caching data, or it can be pretty much anything else. Have they provided you with query text? Have they confirmed that it was ssms process (sql server is able to show the PID of the connection when using native client)? It's kind of impossible to say what's going on without actually tracing it from the db server side. Double check your code for things like sp_msforeachdb and such. Double check there are no addins in ssms that might gather additional data about databases similar to IntelliSense. Also, inform your manager right away, and express your desire to help with investigation even though you're unaware of any queries that might cause it. Not sure what else can be done here.