Powershell to get Results and Messages in SSMS inquiry
Is there a powershell script that will show both output Results and Messages. For example:Select @@servernameIt should show on the powershell outputResult - Server/InstanceNameMessages- (1 row(s) affected
View ArticleEnumerations in PoSh prior to V5
I'm trying to create an enum of our SQL Servers[code="other"]Add-Type -TypeDefinition @" public enum OurServers3 { Srv1, &nbs
View ArticleHelp a newbie with Powershell and XML?
I have an XML file as follows:<Projects> <Project ProjectName = "DeploymentPackageTest" ProjectFolder = "Test"> <Parameters> <Parameter parmName = "LocalHostTest_ConnectionString"...
View Articleadd filename extension
I found this script online and would like to add a datestamp to the file.Schedule this to run everyday. How do I do this?Thanks[CmdletBinding()]Param ( [Parameter(ValueFromPipeline)] [string[
View Articlepower my PS script to automatically connect via SQL authentication and...
Hi ,I have an working PS script that works via windows authentication so it appears. I have a specific server where i am denied windows authentication on the SQL server level but provided with an SQL...
View Articleinvoke-sqlcmd and stolen single user session
HiI run following sql script (part of script file) file with invoke-sqlcmd:...[code language="sql"]if db_id('xxx') is not NULLBEGIN if (select state from sys.dat
View Articleusing New-AzureRmSqlDatabaseImport for importing database in azure sql database
Hi all,I am trying to find out when using the following New-AzureRmSqlDatabaseImport cmdlet to create a new database from bacpac file. This is all being done on Azure. There is a parameter called "
View ArticleGetting started with Powershell
Hi allI'm just getting started with PowerShell and following the series by Ben Miller here. I'm trying to do things properly and learn rather
View Articlerestore-sqldatabase dynamic relocate files
I'd like to use restore-sqldatabase to automate a nightly refresh and am trying to dynamically pass values for the RelocateFile parameter by building an array:[code language="sql"]#Find the appropria
View ArticleParameters to supply drop down choices, do they work in Azure Powershell...
Hello,I have previously written powershell scripts that basically eliminates human typo errors by providing choices to choose from. I would like to ask anyone that may have created Azure powershell...
View ArticleDeploy Script To SQL Databases using Powershell
Hello all.I am new to powershell and have a question. Is there a way to deploy sql scripts to all the databases that are in a registered server in the central management list on sql? I would like to...
View ArticlePowershell experts, I need help with dynamic parameters. Posh V5. First Param...
Hello,I am really trying to get my head around dynamic parameters, but I just dont know enough PS to get this right. I'd like to select an environment from a drop down (validateset, no issues here),...
View ArticleRemove-Item giving error and not accepting path passed thru variable
Here is the code I am trying:[string] $Server= "ServerName"[string] $Database = "DBName"$UserSqlQuery= $("select FileDelete from DBName.dbo.tmp_TableName")$resultsDataTable = New-Ob
View ArticleI want script for log shipping monitoring report
I want to execute powershell script on log shipping. It will show primary and secondary server output in HTML
View Articleemail with attachment powershell
This code runs successfully but does not send an email.Any help is appreciated.Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyContinuefunction sendmail_withAttachment...
View Articlesubmit batch of sql inserts as string or submit one insert at the time to...
Case1 $sql =" INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1'); INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1',
View ArticlePS script works in ISE but fails in SQL JOB step with a syntax error
I need to copy a subset of rows from a table on a (sql2016) server, to a table on a (sql2008r2) server. Old approach was SSIS; I wanted to see if I could do it in PS more simply.I found this article...
View ArticleIs anyone scanning event logs with powershell?
Wrote my first poweshell function and used get-eventlog. Problem it runs very slow even with filtering on a dozen servers. I just read about get-winevent, but people complain about about similar...
View Articlescript Powershell simple to recovery mode
HelloI will need to set up an automatism that checks the recovery mode of the bases If base other than SIMPLE, force the transition to simple mode and shrink database [code language="s
View ArticleExecute SQLs in Parallel from directory
Hello - I am newbie to powershell. I am able to execute all the .SQL files from directory on to the server serially using below command. But, we want to execute all these files in parallel. CAn someone...
View Article