i am using powershell to get the output..I am planning implement sorting to my output.below is the format I am writing my objects to html file.I want sort the object of lastrunoutocome field.
1) I can connect to SQL Server 2012 named instance from SSMS.
I can launch Power shell in any of the supported data contexts, for example from the named instance.
However when I try to run a query in Power Shell, I get the named pipes error.
2)I can also provide a connection string and connect to the SQL Server Instance form Windows PowerShell after launching SQLPS, the same as in the above. I can open the connection and verify its state, but trying to run a query results in the same error.
I also see that named pipes is enabled in the SQL Server Configuration Manager.
Some of this is the result of some ambiguity in the Windows User Account in Windows 8 computer. Some of this is documented in more detail here: [URL] .....
This link is not directly related to the above problem, but arises out of the ambiguity in the Username retrieval: [URL] ....
I am looking for a sample PowerShell script that allows me to verify that showplan is enabled for a user on a SQL Server 2012 instance. Haven't figured out how to code it.
We have 15-20 report server environments including Dev/SIT/UAT/PROD/DR etc. so instead of configuring it on each servers, we would like a script to use with parameters.
After installing the SSRS 2012 package on each server with given instance and service account, I would like to configure the SSRS through script instead on running the Configuration manager RSConfigTool.exe manually.
we already have created the database beforehand using the scripts provided by WMI. do we need db_owner permission on msdb and master database to configure SSRS?
I am trying to delete tables from data where the ModifiedDates older than 9 years in AdventureWorks2012 database . I get console notified that foreign keys are dropped but the delete statement is throwing errors. I am sure that somewhere the key constraints are not getting altered, but i'm not able to figure it out as i'm a relative beginner to T-SQL. The error and code:
The DELETE statement conflicted with the REFERENCE constraint "FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID". The conflict occurred in database "AdventureWorks2012", table "Sales.SalesOrderHeader [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null $option_drop = new-object Microsoft.SqlServer.Management.Smo.ScriptingOptions; $option_drop.ScriptDrops = $true;
We are in plan to build a Monitoring tool using PowerShell and Performance Monitor which could monitor 10 to 20 servers. Do you have any reference of any existing tool using Performance Monitor to monitor the SQL Server and available for free? I didn't want to put some effort, if something is available already.
I have an interesting challenge. Imagine I own a pizza restaurant and I have delivery drivers (4). I also have a fixed number of delivery Routes for my restaurant and these routes have varying number of households on the them. I want to sort and assign the routes as evenly as I can to the drivers.
Drivers: ------------------------- 1 - Bob 2 - John 3 - Ricky Bobby 4 - Batman
What I'm TRYING to is write a Stored Proc to loop though the records (routes) and assign them to the drivers as evenly as possible based on households (staying with whole integers).
I've tried a couple of different concepts but keep hitting 'writers block'.
I have an execution plan that is huge, the pdf it generates if I print it is over 1000 pages. Is there a way to change the graphical plan into a table, so I can sort the %, and find the items that are taking the longest?
INSERT INTO #Activities VALUES('Field phase S14-04932-01') INSERT INTO #Activities VALUES('Phase reporting') INSERT INTO #Activities VALUES('Phase running') INSERT INTO #Activities VALUES('RD1')
I have a report where I am giving the users a parameter so that they can select which field they would like to sort on.The report is also grouping by that field. I have a gruping section, where i have added code to group on the field I want based on this parameter, however I also would like to changing the sorting order but I checked around and I did not find any info.
So here is my example. I am showing sales order info.The user can sort and group by SalesPerson or Customer. Right now, I have code on my dataset to sort by SalesPerson Code and Order No.So far the grouping workds, however the sorting does not.
SSRS 2012 - VS2010...The report compares two years with a sort order on a value that has been engineered based on text switched to int. When sorting A-Z this is the result in the horizontal axis is: 5th, K, 1st, 2nd, 3rd, 4th, 5th..When sorting Z-A the result in the horizontal axis is:5th, 4th, 3rd, 2nd, 1st, PreK..Z-A is correct but A-Z sorting shows 5th as the start and end. The magnitude of the PreK location is correct but the label is wrong on the A-Z sort order. The sorting is implemented using the Category Group sorting option.
USE [Testing] GO /****** Object: Table [dbo].[Testing] Script Date: 4/25/2014 11:08:18 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON
[Code] ....
It seems to work fine with one million records.
Each primary key is unique, but the begindate is non-unique, and i guess even if i use datetime2 and add nanoseconds, from what i have read, there is a chance that i could have a duplicate datetime since the date is imported via XML from multiple sources.
Hi, I am trying to get performance data using powershell. When I run the command "get-wmiobject -list" I get classes like Win32_PerfRawData_MSSQLSQLEXPRESS1_MSSQLSQLEXPRESS1Locks. However when I run the command
get-wmiobject -query "select * from Win32_PerfRawData_MSSQLSQLEXPRESS1_MSSQLSQLEXPRESS1Locks" powershell gives me an error. Why is this happening? any help in this regard is appreciated.
I would get from scripting the replication out from SQL Server itself. However, there are a couple of things that are not showing up in the script,Adding the option to IncludeUninstallDistributor or UninstallDistributor doesn't appear to add any code to actually do that. i.e. the below code is never added.
/****** Uninstalling the server as a Distributor. Script Date: 10/1/2015 4:34:13 PM ******/ use master exec sp_dropdistributor @no_checks = 1, @ignore_distributor = 1 GO Also, adding the reverse for the create script generation, IncludeInstallDistributor or InstallDistributor, does not add the below code. use master exec sp_adddistributor @distributor = N'xxxxxx', @password = N'' GO
The purpose of the script is simply to script out all drop/create scripts for all publications and subscriptions, run the drop script, restore over the databases using backups of non-replicated databases, run the create replication script, and have it re-sync.
I would like to use powershell commands within my TSQL scripts. how to do that?
The reason is that up until now I have been using SQLCMD and XP_CMDSHELL to rename files before importing them into a database. Powershell is a better tool for this job.
As a part of DBA, I used to execute various SQL files. Most of the time, it is like a manual effort to execute the files individually.
I am looking to automate the process, like a single click to execute all the .SQL files.
The main hurdle I have is, some files needs to be executed in A1 database, some in B1 database and some other SQL files need to be executed in C1 database. In this scenario, I need to pass the DBName information to the powershell query dynamically.
My design for this requirement is, say each .SQL file need to contain a template like
@DBName = 'your Database name' @Executeon = 'When to execute'
In this case, the powershell first need to read the SQL file and finds the value for @DBName and replace it in the powershell query and execute the SQL files automatically.
Is it feasible ? Or any other alternate easier way to proceed.
I have a job which copies .txt files 24 hours 7 days a week to c:TempSource
What I am planning to do is copy the files from one location to another say c:TempTarget
So I have written the Powell shell script and when i put that in the sql agent job i get below error ;
A job step received an error at line 5 in a PowerShell script. The corresponding line is '$filesToMove = $files | Where -Property "Name" -NotLike -Value $newestFile.Name'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'A parameter cannot be found that matches parameter name 'Property'. '. Process Exit Code -1. The step failed.
I have a new problem with doing a restore of a number of databases using powershell. The script I'm using is based mainly on this one (Part 2 in particular): [URL] .....
The problem I'm having is around the RedgateGetDatabaseName function. My hunch is that its down to the different version of red gate and how sqlbackup works. Basically when the call is made to the function it is returning both the Database Name and the number of row's that the SQL command in the function has ran. I've tried to include a SET NOCOUNT ON at the start of the SQL command in the function but its still returning the now count.
When I execute the following command, I get the output truncated to 79 characters, including three dots (as an ellipsis, I suppose).
EXEC master..xp_cmdshell 'powershell.exe "Get-ChildItem D:Databazepaleontologieprilohyverejneg -filter g417*.* -recurse | select Fullname | out-string -width 255"'When I execute the core command directly in Powershell, whether the text or ISE version, it works correctly, with or without the out-string -width command.
Get-ChildItem D:Databazepaleontologieprilohyverejneg -filter g417*.* -recurse | select Fullname | out-string -width 255What does it take to get SSMS to not truncate my output strings?
I have a SQL Server 2014 instance running on a SQL Server 2008 R2 server. The server is not clustered, it is just a stand alone SQL Server. The syspolicy_ purge_history job fails every now and then with the error message: "A job step received an error at line 1 in a PowerShell script. The corresponding line is 'import-module SQLPS -DisableNameChecking'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Access to the path 'PowerShell_CommandAnalysis_Lock' is denied. '. Process Exit Code -1. The step failed."
Google isn't bringing up much besides the whole"If this is a clustered server make sure you have the right server name in the command" answer, which isn't the case here. Some days this job fails and some days it succeeds. I have checked out task scheduler to see if there were any conflicts there, found nothing. Nothing in the event viewer either.
I'm trying to create a restore job for restore job in sql using PowerShell but I get the following error:
The job script encountered the following errors. These errors did not stop the script:
A job step received an error at line 1 in a PowerShell script. The corresponding line is 'Set-location "filelocation"'.
Correct the script and reschedule the job. The error information returned by PowerShell is: 'Cannot find path 'filelocation' because it does not exist.
' A job step received an error at line 3 in a PowerShell script. The corresponding line is 'get-childitem -Filter '*.trn' | Select FullName, LastWriteTime | sort LastWriteTime -Descending | ft -AutoSize'.
Correct the script and reschedule the job. The error information returned by PowerShell is: 'Cannot call method. The provider does not support the use of filters. '. Process Exit Code -1. The step failed.
As we know there are two output windows in sql server management studio like 'Results' and 'Messages', I want to capture that 'Messages' window into a log file using powershell program . like into a log file it should display like :
I am trying to update my SQL table using an update query in powershell from an excel sheet.
The query is as follows,
#building name from excelsheet $TCell=$reader.GetValue(8); #update query is as, $CreateScript1= "UPDATE $DestinationTable SET $DestinationTable.Phone = '$SCell' WHERE RoomNumber = '$FCell' and buildingname like ''$TCell'%'"
I want to use like operator in the query to compare building name from excel sheet with the building name in sql table. I am facing an error in the highlighted part. I am not sure if my query is right or wrong.
I am trying to automate the setup of SQL server 2014 Standard edition with SSRS. To avoid SSRS being setup using the default port 80 for the webservice and report manager url's, I've chosen to install SQL server with the setting RSINSTALLMODE="FilesOnlyMode" and then use powershell to do the final setup steps.To setup the ReportServer database, I use the "GenerateDatabaseCreationScript" method available in the "MSReportServer_ Configuration Setting" class.
This succeeds without problems however when I use my browser to connect to the web service or report manager url's, I get a "rsInvalid Report Server Database" and a "rsReportServerDatabaseUnavailable " error, respectively.Running the stored procedure named GetDbVersion in the ReportServer database returns "C.0.9.45". If I delete the ReportServer database and then recreate it database manually with the Report Services Configuration manager, the same stored procedure returns "162".
So it seems to me there's a problem with the GenerateDatabaseCreationScript but I can't find any information on this. How can I automate the setup of SSRS and ensure it does not use port 80? There are many manual solutions involving multi-step GUI solutions but the key for me is to automate this with powershell which doesn't appear to be possible.
I am trying to create a job using power-shell script to move the backup files from one folder to another. I am using Ola Hallengren script for backups. Ola hallengren created a common backup folder with sub-folders for databases and even more sub folders for Full and Log backups. My goal is to move full backups, which are older than a month and save them in a different drive along with the same folder structure. I was able to move the first set of backups without any problem, but I can't move anymore files and keep getting this error even when I try to overwrite the previous file with the force statement:
Move-Item : Cannot create a file when that file already exists.
In case of command execution from project PowerShell SSIS, writes only Failure to what there can be a problem? From VS it is launched without problems.
I want to run a powershell script using xp_cmdshell, put the results into a temp table and do some additional stuff.I'm using:
CREATE TABLE #DrvLetter ( iid int identity(1,1) primary key ,Laufwerk char(500), ) INSERT INTO #DrvLetter EXEC xp_cmdshell 'powershell.exe -noprofile -command "gwmi -Class win32_volume | ft capacity, freespace, caption -a"' select * from #DrvLetter SQL server is cutting off the output, what I get is (consider the 3 dots at the end of a line):