Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Browsing index pages (467 articles)

change the credentials for SQL Server Agent on all the nodes of a cluster

I'm running into a problem on a simple powershell script to change the credentials for SQL Server Agent on all the nodes of a cluster. Something is going wrong when I pass values to the...

View Article


skip function if completed successfully

I have a function where I'm executing in succession a list of sql queries\updates. The function has try\catch so if it detects error. My questionis( hopefully asking correctly) is there a way if one...

View Article


Get Max Number of error log files

Creating Audit script to validate newly built sql server- as it's popular now- in PS. Do not have much experience with PS- learning on the fly- moving slowly but steadily. Stuck with validating Max N...

View Article

Help with List Variable

Hi, Please could anyone help me with following requirement. I have output like below -

View Article

List edition and version of all SQL Server machines over the Network ...

In our organization, we have more than 100 SQL Server machines on different regions over the Network/LAN/WAN. We have restricted the network to do not go out of subnet/your allowed access until...

View Article


Run New PowerShell Process As A Different User

Hello,I'm trying to create a PowerShell script that will run a new PowerShell Process as a different 'Windows' user.  The following code seems to work for running the new process as the different user,...

View Article

WMI connection error using Invoke-Sqlcmd

Hi all,I'm brand new to powershell and am trying to convert an old batch script that run some sql files via sqlcmd command to a powershell script.This is my test script so far:[code la

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


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


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

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

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

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


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

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


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

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


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

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

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
Browsing index pages (467 articles)


Latest Images