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

Concat hard value to each row of Hash Table

I'm a newbie to Powershell and this one is driving me nuts. I have a document with many many rows of data and many columns for each row. I am sending this data via HTTPS post to a webserver and need to...

View Article


Encoding data with Powershell

I'm pulling a text file into Powershell so I can send it via HTTPS. But as part of the send, the data needs to be encoded as Multipart/Form-Data (MIME) format. I'm unsure if that's automatically a part...

View Article


SQL Server Detach database

HiI am a SQL Server DBA and have never used Powershell before. I'm trying to detach a database using Powershell, but not getting very far.Have read up a bit and most ppl do it like below. I tried to...

View Article

Add Network Places using PoSh

I'm getting a new Windows 7 desktop. From a powershell perspective, probably a good thing.But, I have a goodly number of Network Places mapped on my XP box, and I'd like to re-create those mappings on...

View Article

Programmatically create a New Network Location link Windows 7

Still trying to programmatically create a New Network Location link.I've got it down to -- [i]I think[/i]:$Newlink = New-Object System.IO.DirectoryInfo "$MyPath"But I can't figure out how to set the...

View Article


Powershell Test-Path hanging

I am running a script that checks for mdf and ldf files on all of our SQL Servers and the script gets about halfway through before it hangs. It hangs at the line:[code="other"]Test-Path...

View Article

MSCluster gwmi access denied...locally on node..

Has anyone experienced this? I'm getting an access denied when trying to access Cluster WMI Objects...but only on a local node. I can access the objects just fine from other locations.

View Article

powershell WMI error: "Could not obtain SQL Server Service information. An...

I get the following error when I launch powershell from SSMS, after right-clicking on a remote SQL instance and choosing "Start powershell":[quote]Warning: Could not obtain SQL Server Service...

View Article


Copy files using Powershell

Hey guys, I'm trying to figure out how to copy backup files from one shared location to another. I'm looking to be able to delete files at the destination, that no longer exist at the source, so what...

View Article


SQLPS takes 30 minutes to import. How to fix it?

Hey SSC,SQLPS on my workstation used to take around 30 seconds to import. Not exactly speed-of-thought, but acceptable.Now it takes around 30 minutes! This is unacceptable because it blocks my...

View Article

Managing Connection properties of Maintenance plans using Powershell

Hi All,We are managing the password reset activity from a central server for a login which is used on our servers for executing jobs and maintenance plan jobs.We are using the below powershell script...

View Article

Agent job with powershell

HiI am trying to create an agent job that looks for a file to exist and file if the file is not fount. I am using a try\catch block but the job will not fail. Any ideas?try { Get-Item -Path...

View Article

Set_Login Error in powershell script

Hi All,I was trying to automate my Password reset activity for Sql Logins from a central servr using Powershell.With the help of some useful tips from the below link, I was able to create a script :...

View Article


Passing Parameter to SQl Agent Job that runs powershell

HiI have created a SQL Agent Job with a powershell step. The powershell script looks like the following:[code="other"]Param( [string]$A, [string]$B, [int]$C)#Do something with $A,$B and $C[/code]Now I...

View Article

Powershell exit code

I have a script that I'm trying to run in TeamCity, essentially I want to force an exit code if an error happens.Here's the script:[code="other"]$s = "kbullen-865";$db_name = "tempdb";$ExceptionMessage...

View Article


Cannot open file because the current provider (SqlServer) cannot open a file.

Server has SQL 2012Opened powershellsqlps got PS SQLSERVER:\> promptPS SQLSERVER:\> echo "xxxx" > tempps.txt[b]This works fine in normal powershell[/b]. In sqlps I get error:Cannot open file...

View Article

Using a Helper Library from a powershell script that will be running via a...

Hi I am having a Powershell Script, [b]A.ps1[/b] that calls some functions from a Helper script [b]HelperFunctions.ps1[/b]. In order to execute A.ps1 from console I make sure I have the helper script...

View Article


Unable to run the PS query.

How to check if I have a list of SQL Servers in a .TXT file and in the list, what are the SQL Servers are not accessible/stopped/not working?$MachineList = get-content...

View Article

How to find number of columns returned from query in powershell

I want to find out number of columns returned from a query in a powershell script.As we will be passing a dynamic query which can retrieve only 2 columns or 5 columns or n columns based on user's...

View Article

email if no new files in last 2 days

I have this code that works great if there is a new file in the last 23 hours. how can I adjust it that if there is no new files in the last 2 days it will send me an emailParam ( [string]$Path =...

View Article
Browsing all 467 articles
Browse latest View live