0
votes
1answer
188 views

Installing SQL remotely using Invoke-Command

i'm trying to install SQL Server 2012 on Win 2012 r2 server remotely via Powershell using Invoke-Command, but it fails with this error "Validation for setting 'SQLSVCACCOUNT' failed. Error message: ...
1
vote
1answer
79 views

What happens to active connections to my SQL Server DB if I back up the transaction log with the NORECOVERY option?

Some background: I'm migrating my SQL Server DBs to a new machine and I wrote a few Powershell scripts to send/apply full backups and transaction logs asynchronously to the new server, but my question ...
1
vote
1answer
510 views

Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps'

I've tried re-installing SQL Server 2014 and I'm still getting the following error message when trying to import-module sqlps. The same registry key exists but is appended with 120. I'm able to use ...
1
vote
0answers
33 views

Why is $job.LastRunOutCome always “Failed”?

I am using sqlps to run a backup job "Backup Something". Set-Location "SQLSERVER:\sql\$hostname\default\jobserver\jobs" $job = Get-ChildItem | Where-Object {$_.Name -eq "Backup Something"} ...
2
votes
1answer
438 views

Powershell script runs in an infinite loop when executed a certain way

I'm using the Exec Powershell provider for Puppet to run some powershell scripts. I'm having an issue with the way it executes my script. The method of execution causes the script to run over, and ...
2
votes
1answer
193 views

MSSQL Server 2012 Scheduled PowerShell Job fails

I have a simple PowerShell script that runs fine from the console (PSVersion 2.0). $psftpPath = "C:\Program Files (x86)\PuTTY\psftp.exe" $sftpHost = "foo.baa.com" $userName = "myusername" ...
0
votes
2answers
466 views

Ban IP address based on X number of unsuccessful sql server login attempts?

Is it possible to expand on the idea presented in Ban IP address based on X number of unsuccessful login attempts? to encompass IP addresses for repeated failed sql server login attempts? There are ...
1
vote
1answer
1k views

SQL Agent Powershell Job Failing with Non-Admin Proxy

I'm attempting to create a SQL Agent job that will run a PowerShell script that is saved on my system. However, the job fails with the following error: A job step received an error at line 1 in a ...
0
votes
1answer
233 views

PowerShell in SQL Server 2008 R2

In SQL Management Studio there is an option to start PowerShell via right-click on a database (for example). However, I cannot run queries from that PowerShell session because, it claims, the login ...
4
votes
2answers
1k views

How do I use PowerShell to find out what jobs failed within the past 24 hours?

Long time DBA, but new to PowerShell. I'm looking to use PowerShell to loop through several SQL Server instances and find out what jobs failed within the past 24 hours. I need to know failures even ...
0
votes
2answers
622 views

Using powershell to gather disk used into a sql table

I have a script which connects to a db to get a list of servers to query and then queries them for disk space using a wmi query. Now I'd like to get these results into a table. I've run into a few ...
3
votes
3answers
2k views

What is the best powershell script to restore an SQL Database?

To restore an SQL Server 2008 database, I would lile to be able to just do something like this in powershell: ./restore.ps1 DatabaseName.bak Then the powershell script would by convention restore it ...
1
vote
1answer
348 views

Backup database from default (unnamed) sql server instance with powershell

Trying to connect to an instance of SQL Server 2008 on a server we'll call Sputnik. There are no firewalls in between the two devices. Right now I'm just trying to list databases ...
3
votes
3answers
2k views

How do quotes/strings work in Powershell?

I'm have a command line that works in the regular old Windows Command Shell, but somehow gets misinterpreted in Powershell (I'm fairly new to Powershell). sqlcmd -S .\SQLEXPRESS -i ...
1
vote
2answers
725 views

What version of PowerShell is required for SQL Server 2008 R2?

Today I tried to install SQL Server 2008 R2 Express on my computer but I the installation failed, it said that PowerShell must be installed on it. My question is then, what version of PowerShell ...
0
votes
1answer
296 views

Get-ChildItem fails to connect in SQLSERVER drive

I'm having some trouble with the SQLSERVER PSDRIVE. See error below. I only have named instances on my PC, both 2005 and 2008 Added the SQL snapins. The PC is named YODA The SQL instance is SQL2008 ...
2
votes
1answer
840 views

How to enumerate SQL Server role members with Powershell?

I have a powershell script to enumerate the members of SQL Server role members using powershell. I have this script <... cut the connection details for brevity, $SqlInstance is a ...
1
vote
2answers
458 views

Powershell command to confirm SQL Server Smo.Server object is valid

I had the following code in a PowerShell script: $sql_instance = "SQLEXPRESS" [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') $server = New-Object ...
2
votes
3answers
458 views

SQL Server without Powershell

I'm trying to install SQL Server 2008 Express Edition, and it's demanding Windows Powershell and refusing to proceed with the installation. Is there any way to get it to install without Powershell? ...
1
vote
1answer
552 views

How to schedule SQL-Agent to run a maintenance plan every x minutes?

My name is aSkywalker and I am an involuntary DBA. I have done some research, and would like to back up transaction logs every 10 minutes. I have written some powershell scripts to compress, encrypt ...
5
votes
2answers
2k views

How can I use powershell scripting to change SQL Server Aliases?

I have an x64 machine that regularly needs about 10 aliases changed in the SQL Server Client Network Utility (cliconfig) for both the x64 and x86 sides of the registry. Is there a way I could do this ...
4
votes
3answers
401 views

Looking for a script to restore a SQL server backup

I'm looking for a script to restore a SQL Server 2005 backup. Ideally the script will have the following features handle backup files on a network location Handle different file structure of source ...
0
votes
3answers
805 views

Cannot start SQL Server PowerShell

Have you guys had this problem where, when you start PowerShell from SQL Server, it throws an exception like the following? Cannot resolve alias 'cd' because it refers to term ...
37
votes
22answers
14k views

PowerShell? Do you use it? Can you show me some cool system administration things I can do with it?

I keep reading everywhere that PowerShell is the way of the future. When it was first released I did a whole bunch of virtual labs, but since then I still haven't used it in a production environment. ...
9
votes
4answers
1k views

Powershell command to backup a SQL Server DB

Is there a PowerShell command that will execute a backup of all databases on a server? Alternatively, can I call a stored proc from PowerShell (that will execute the backup)?
7
votes
8answers
293 views

Is Vanilla Powershell Enough of a Language for Windows & DB Server Admins?

Does a clean install of PowerShell on its own have enough functionally to Admin a Windows domain environment and/or SQL Servers? If not what are good, free or pay for, third party add-ons?