Deploy Dacpac on remote machine using Powershell
Hi, I am on machine A with windows credentials say UserA and corresponding windows password. I will run powershell script on this machine. SQL 2016 DB is to be deployed on another machine say B. but...
View ArticleNeed Powershell command to list # CORES per computer -- qualified by Computer...
We need to list #CORES per SQL Server Computer in our environment. (we have over 200 SQL Servers). This Powershell command works great for 1 computer:Get-CimInstance -ClassName 'Win32_Processor' |...
View ArticleDbatools Credential issue ?
I am trying to use the Dbatools powershell module, but when I try to pass an AD credential, it is not seeming to work for me. I tried using both Invoke-Sqlcmd2 and Invoke-DbaSqlquery. I am passing a...
View ArticleIs this way of writing code flexible enough for many administrative tasks?
I know there are multiple ways to skin the powershell cat and am currently settled on this solution.In this example, I use 'Microsoft.SQLServer.Management.SMO.Server' to retrieve data (rather than a...
View Articledate formats
((Get-Date).AddMonths(1)) gives meSaturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')gives me July, 2018How do i get August, 2018 when I run code in the month of July with the output in this form
View ArticleExecute Powershell script from SSIS using UNC Path
I'm trying to execute a Powershell script that sits on a network file share using SSIS Execute process task. When I run the package locally, it works fine, but when I run it on my server using SQL...
View ArticleError Powershell
Hello everyoneWho can help me is what exactly is wrong in my scriptmy goal is to launch the command [code language="sql"]exec xp_readerrorlog 0,1[/code][code
View ArticleConvert VbScript Com object to PS to load sql2005 DTS pkg
Trying to Convert VBScript Com Object to PS. VbScript:Set objPkg = CreateObject("DTS.Package") objPkg.LoadFromSQLServer machine,,,DTSSQLStgFlag_UseTrustedConnection,,,,packageName...
View Articleget-childitem in multi path
Hello everyonehow to run the get-childitem command on multiple pathIn fact I have more path and I want to apply get-childiteam on these pathI have in my code $path,$path1,$path2[code langua
View ArticleProblems with getting my hash table populated
HelloI'm trying to to insert values of sql server script into my hash table to be used later on another process, the piece that I'm using is:$instancename ="instancename"$databasename...
View Articleinsert the errorlog in sql table
Hello everyoneI am looking for a method to insert the contents of this script into a sql server table[code language="sql"]Import-Module sqlps -DisableNameChecking$serveurs=@("localhost\sqlprod","loca
View Articleuse Powershell scripts on a Non-sql server
I inherited Powershell scripts that run on a non SQLServer box A and invokes invoke .net commands to connect to SQLserver databases on another box and return datasets. I have the task to install a new...
View ArticleUsing Powershell and code encryption. New to this stuff
Below is a powershell script. Looks like it is encrypted with a signature block. I want to make a small change to server name in the script. After the change i have to encrypt the ps1 file again with a...
View Articleparse string and check for valid date
I have a flat file with a bar(|) delimiter. It has no headers, but I want to check columns(11,12,13) for valid dates. If invalid date found in any of the fields display entire record andfail the...
View Articleinvoke-sqlcmd timeout
Hi everybodyWho can help me on invoke-sqlcmd-level timestamp i tried it with invoke-sqlcmd2 but I still have pb
View ArticleHow to output everything to a log file in Invoke-SqlCmd
I have powershell script to run database scripts below, but I can't get it to output to my logfile the "..x row(s) affected"(the messages that you see in SSMS) output whether I run an update, delete,...
View ArticleList all ADGroups and all their Users
ForEach ($Group in (Get-Content c:\text.txt)) { Get-ADGroupMember $Group | Select @{Label="Group";Expression={$Group.Name}},Name,SamAccountName }I have the above piece of powershell code which displays...
View ArticleSQL Agent job not failing when Powershell script errors
First time using Powershell. And I'm trying to execute via SQL Agent job. So I don't know if I have something wrong in my Powershell script or my SQL Agent job or Both. SQL Server 2008 R2 PowerShell...
View ArticleApplication Intent with Invoke-SQLcmd
Are you able to specify read-only routing in invoke-SQLcmd? $dataTable = Invoke-Sqlcmd -Query $Query -Database $SourceDatabaseName -ServerInstance $SourceServerName ; maybe add something like -READONLY...
View ArticleServices
I need to go through a list of SQL Servers from a SQL table;hit the respective server and collect this data (SystemName, DisplayName, Name, State, Status, StartMode, StartName) and insert those values...
View Article