Invoke-Sqlcmd Count
Hello,I searched for this on here and google and didn't see an exact answer to my question, so sorry if it's been asked and answered before. If I run a query using Invoke-Sqlcmd and put it in a...
View ArticleWindows Batch, VBScript and PowerShell
I have written tons of Windows Batch scripts and compiled VB6, however not as much VBScript. That said, I seen have entire books about managing Windows with VBScript and I know there are many people...
View ArticleSSRS report powershell script
I have SSRS 2008R2 reporting having 3 data sources.Say reportname = \Marketing\Test.rdlDataSource name = \Shared DataSources\Data1 , 2 ,3Now when deploy the report using reports manager upload...
View ArticleHow to pass a response to a .exe called by PoSh
I'm calling an command line .exe from within a PoSh script. This is generating a hit Y for Yes / N for No choice. How can I send a Y in my PoSh script?Thanks!
View Articlecollecting a count of errorlogs using posh
Hi, I am running a script to collect a count of all errors in the current error log using smo, as below:$sqlServer = new-object ("Microsoft.SqlServer.Management.Smo.Server") "MYSERVER"$logs =...
View ArticleGetting printers on a remote PC in a workgroup
I'm trying to learn PowerShell. So I did a [b]Get-Help Get-Printer -examples[/b] and saw that I can issue the command [b]Get-Printer -ComputerName[/b] [i]<computer name>[/i]. So, that's what I...
View ArticleRisks/Best practices on execution policy
While it would be easy to set the execution policy to unrestricted, or possibly set it to unrestricted in an agent job, do the work, then set back to restricted, I'm wondering what the best practices...
View ArticleDetermining if a server is clustered or stand-alone
I'm in the process of writing a powershell script to inventory my SQL Server environment. In collecting the server information, I'd like to grab the physical hostnames that make up any clustered...
View ArticleSql Inventory Script: Fill method fails
I found a sql server inventory script that seems to be available on several sites. It actually seems to generate all of the reports but fails on the SqlDataAdapter fill method whether named pipes is...
View ArticleRun SSIS package from Powershell
I have the following powershell script:$html_file_dir = "C:\Scripts"$cvs_file = "C:\Scripts\SpaceFiles\DiskSpace_20130327060003.csv"$loadFile = "$cvs_file"$dbServer = "."$dbName =...
View ArticleINSERT statements containing regex as a string being read as regex
I am attempting to run a sql script with 4 simple INSERT statements. Each of the 4 INSERTS is inserting a regexp as an NVARCHAR string. 2 of them have within the string the combination of "$(" without...
View ArticleOrphaned DB?
So I am exploring PowerShell, and found a DB with .Databases that I can't see in sys.databases.I ran this following (starting from the Machine level with sqlps):[code="other"] $i = ls $i |...
View ArticlePass parameter into XML file using Powershell
Hi,I have a project to automate SQL server restore.........use restore db's using third party tool called Simpana, Commvault.....we would like to automate the restore using powershell....i can restore...
View ArticleCan't script the schema for a FK
Hi,I use the below script to script out FKs in a database:#DECLARE TIMESTAMP FOR THE FILES$timestamp = Get-Date -Format yyyy-MM-dd#SCRIPTSL SQLSERVER:\SQL\'MyServer'\DEFAULT\Databases\'MyDB'\Tables$so...
View ArticleProblem copying .bak with "$" in file path/name (PS running in SQL job step)
I'm using OLA's SQL JOBs to do my database maintenance. So far, I really like them; they're very handy, especially when apps create new databases each month (WILDCARD dbnames!).I have to copy files...
View Articlehow can i get Powershell
to search stored procedures for server names?we have the list of server names, but not sure if we must script the procedures out and search for server names from the server name list on the file system...
View ArticleRetrieve data and log file names from SQL database
Hi,I'm trying to pull the logical and physical file names from sql server database using powershell and add those values in exisiting xml file...This whole process is for database restore...we don't do...
View Articlereplace string in path using powershell
Hi,i'm trying to get the default sql server data and log file path using the below script...[quote]param($ClientName,$DESTINATIONDB)$SqlConnection = New-Object...
View ArticleInserting Active Directory Data into a SQL Server table
I wanted to gather Active Directory data into SQL Server table to analyze permissions on critical data. I wanted to use a SQL Server Agent Job that would refresh a couple of time per day. I also wanted...
View ArticleUnable to automate the Script
The below script provides the list of trace files available to the location : D:\Trace$fileEntries = [IO.Directory]::GetFiles("D:\Trace\"); foreach($fileName in $fileEntries) {...
View Article