tag:blogger.com,1999:blog-5108764196195021320.post10637693473908928..comments2022-03-04T15:47:00.866-05:00Comments on The Ashdar Partners Blog: Using Powershell in a SQL Server 2008 job stepDarin Straithttp://www.blogger.com/profile/04921427390476369554noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5108764196195021320.post-84864899603918002022013-09-06T09:43:58.721-04:002013-09-06T09:43:58.721-04:00I apologize for the delay. I haven't been chec...<br />I apologize for the delay. I haven't been checking the blog as often as I used to and I seem to have lost email alerts for blog comments. I'll be checking my spam filters and blog configuration shortly. <br /><br />I haven't had that problem and I don't currently have a SQL Server 2008 system to test with. One thought is: do you have SSAS installed on the same server as your SQL Server? Perhaps the requisite client DLL isn't installed unless you have SSAS installed? If I were using SQL Server 2008R2 or 2012, I would be looking at use of <i>import-module</i>.<br /><br />I tend to install all of the SQL Server components on all of my machines even if I am sure that they won't be used. I just flag the services that I don't need for "manual start" and ignore them. My reasoning for this is that it is harder to install new components (which could require a reboot) than it is to just re-configure a few things and flag a service for "automatic start". I have had several incidents where a development team claimed that they would never use SSAS/SSRS/whatever and then they were back at my desk six months later, asking for exactly what they said that they didn't want. The storage space for storing those binaries is rarely a problem these days. It does increase the attack surface for that server, but I figure that if someone has enough access to start up SSAS/SSRS/whatever, they have already effectively compromised your machine and the horse is already out of the barn.<br /><br />Darinhttps://www.blogger.com/profile/10442944956131032983noreply@blogger.comtag:blogger.com,1999:blog-5108764196195021320.post-90839881412863679332013-08-01T07:51:27.259-04:002013-08-01T07:51:27.259-04:00Iam getting this error.
New-object : Cannot find t...Iam getting this error.<br />New-object : Cannot find type [Microsoft.AnalysisServices.Dimension]: make sure the assembly containing this type is loaded.<br />Inspite of using your suggestion with partial load.Could you help on this.Sandeephttps://www.blogger.com/profile/12098294892759508899noreply@blogger.comtag:blogger.com,1999:blog-5108764196195021320.post-88030472880532998492011-10-19T16:29:44.226-04:002011-10-19T16:29:44.226-04:00As use mentioned, the sql mini shell seems to call...As use mentioned, the sql mini shell seems to call Powershell 1.0 so Powershell 2 syntax like Import-Module does not work as a SQL PS job step. Has anyone found a way to have sql default to Powershell 2 instead of 1?<br /><br />I can call an operating system task, but would prefer to figure out the Powershell job step approach. <br /><br />I have another issue..SQL 2008 Auditing to Security Log. If you want a PS script that parses the security log later, and you grant all the perms necessary to do that, your PS script will still have UAC issue from Get-EventLog. Running as a scheduled task with Highest Privileges selected does work, but since we are the dbas not the sysadmns, we would like to call this with an agent job. I'm not sure yet if the powershell sql mini shell job step will also bypass the UAC or not but that's why I am trying to test it.Forresthttps://www.blogger.com/profile/00119401008172369865noreply@blogger.comtag:blogger.com,1999:blog-5108764196195021320.post-16585825685133797822011-10-19T16:25:34.954-04:002011-10-19T16:25:34.954-04:00I would like use Powershell 2.0 syntax, and as you...I would like use Powershell 2.0 syntax, and as you mentioned, the sql mini shell does not seem to load PS2. Has anyone found a way to convert the mini shell to the 2.0 provider?Forresthttps://www.blogger.com/profile/00119401008172369865noreply@blogger.comtag:blogger.com,1999:blog-5108764196195021320.post-38420714448080266312010-06-11T14:50:31.532-04:002010-06-11T14:50:31.532-04:00I bumped into issue #8 and ran across your blog. ...I bumped into issue #8 and ran across your blog. My issue was that I wanted to copy files from one location to another using a sql job, but only copy files that were older than 1 week.<br /><br />$src = "\\source\location"<br />$dest = "\\destination\location"<br />$days = "7"<br />$time = get-date<br /><br />$movefiles = get-childitem "$src" <br /><br />foreach ($file in $movefiles)<br />{<br />if ($trc.CreationTime -lt $time.AddDays(-$days))<br /> { <br /> copy-Item $file.FullName $dest<br /> }<br />}<br /><br />The key is making the variable $time.RMBIVhttps://www.blogger.com/profile/18119704720010975657noreply@blogger.comtag:blogger.com,1999:blog-5108764196195021320.post-30787106434745460082010-06-11T14:50:31.533-04:002010-06-11T14:50:31.533-04:00I bumped into issue #8 and ran across your blog. ...I bumped into issue #8 and ran across your blog. My issue was that I wanted to copy files from one location to another using a sql job, but only copy files that were older than 1 week.<br /><br />$src = "\\source\location"<br />$dest = "\\destination\location"<br />$days = "7"<br />$time = get-date<br /><br />$movefiles = get-childitem "$src" <br /><br />foreach ($file in $movefiles)<br />{<br />if ($trc.CreationTime -lt $time.AddDays(-$days))<br /> { <br /> copy-Item $file.FullName $dest<br /> }<br />}<br /><br />The key is making the variable $time.RMBIVhttps://www.blogger.com/profile/18119704720010975657noreply@blogger.com