Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Browsing all 467 articles
Browse latest View live

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 Article


Need 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 Article


Dbatools 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 Article

Is 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 Article

date 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 Article


Execute 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 Article

Error 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 Article

Convert 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 Article


get-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 Article


Problems 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 Article

insert 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 Article

use 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 Article

Using 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 Article


parse 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 Article

Image may be NSFW.
Clik here to view.

invoke-sqlcmd timeout

Hi everybodyWho can help me on invoke-sqlcmd-level timestamp i tried it with invoke-sqlcmd2 but I still have pb

View Article


How 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 Article

List 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 Article


SQL 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 Article

Application 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 Article

Services

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
Browsing all 467 articles
Browse latest View live