powershell

Deploy a Crystal Report programatically?

I'm having difficulty finding directions to programmatically deploy a Crystal Reports XI report to the server for general use. Is there a COM object, Web Service, utility, or something else that can be used to script report deployment? I will need to do this from PowerShell, but can convert from other available solutions. ...

Can I get intellisense in powershell?

Just starting out with powershell, I would love to have intellisense support for writing powershell scripts. Tab-completion works great so you would think it would exist somewhere, but the only thing I can find when Googling is an article from 2007 - hardly up to date. Is there an extension somewhere that gives you this ability? How a...

Integrating PowerShell in SharePoint

For some time I have been looking at the possibility to integrate PowerShell as a scripting engine in SharePoint but I haven't found the right solution yet. My main objective is to enable event triggers in e.g. a list to call and execute a PowerShell script (by filename) on the local server. This would give me a lot of flexibility compa...

Powershell equivalent of LINQ Any()?

I would like to find all directories at the top level from the location of the script that are stored in subversion. In C# it would be something like this Directory.GetDirectories(".") .Where(d=>Directories.GetDirectories(d) .Any(x => x == "_svn" || ".svn")); I'm having a bit of difficulty finding the equivalent of "Any()" in ...

output filename, not string with select-string

I'm using powershell to "grep" my source code for a particular string. If the string is in the file, I would like the name of the file, not the line of code that contains the string. I would also like the name of the file, just once, not listed for as many times as the file exists. I'm currently using: gci . -include "*.sql" -recurse...

Powershell remove user from specific group in sharepoint

I am trying to remove a specific user from sharepoint and have hit a wall. I keep getting the following error You cannot call a method on a null-valued expression. Code: function verifyUsers { $verify_sitepath="https://extranet.mydomain.com" $verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath) $verify_we...

Powershell - find the first file that matches a pattern

I would like to select any one ".xls" file in a directory. The problem is the dir can return different types. gci *.xls will return object[] if there is more than one file FileInfo if there is exactly one file null if there is no files I can deal with null, but how do I just select the "first" file? ...

Powershell, WMI and compressed files/folders

I need to generate a script that will help me in getting a list of compressed files/folders (not zip files, but Windows compressed files) on a range of Windows 2003 servers. I have a client pc connected to the target servers and have access on a administrator role basis. My thoughts was to create a Powershell script to handle this proble...

Does powershell have associative arrays?

I am writing a function that returns an id, name pair. I would like to do something like $a = get-name-id-pair() $a.Id $a.Name like is possible in javascript. Or at least $a = get-name-id-pair() $a["id"] $a["name"] like is possible in php. Can I do that with powershell? ...

With Powershell quickly growing in popularity, is there any reason to learn VBScript?

This is more a general question than anything. I know that VBScript and Powershell can do a lot of the same things and each does things the other can't, but I'm wondering if there's any reason to still learn VBScript or if efforts are best directed into learning Powershell. /matt ...

Does PowerShell STA mode eliminate SharePoint memory leak issue?

Some background: SharePoint+PowerShell is (Usually) a Perfect Match by Zach Rosenfield [MSFT] SharePoint+PowerShell Leak Workarounds by me SO: Could you explain STA and MTA? In short, standard SharePoint guidance is that COM-backed objects like SPSite and SPWeb should not be used by different threads. This stands in conflict with Pow...

Invoke-Sqlcmd cmdlet throws exception when using -Variable parameter

When I try to use the Invoke-Sqlcmd cmdlet from SQL Server 2008 to execute a query that contains scripting variables, ex. $(MyVar), I receive the following exception: Invoke-Sqlcmd : Object reference not set to an instance of an object. Here's the code I'm trying to run (which is copy/paste from the Books Online example with only t...

How to change read attribute for a list of files?

I am powershell newbie. I used a sample script and made substitute from get-item to get-content in the first line. The modified script looks like below: $file = get-content "c:\temp\test.txt" if ($file.IsReadOnly -eq $true) { $file.IsReadOnly = $false } So in essence I am trying to action items contained in test.txt stored as UNC pat...

How to add to types initially loaded in PowerShell?

Evening all, I'd like to know how to add to the list of .NET assemblies that are loaded at start up in PowerShell. Thanks in advance, Dan ...

How to pass Properties to jar from Powershell ?

Hi, I've been using Powershell-1.0 for command line needs for a while, instead of cmd.exe. Unfortunately, there are still some caveats when using java. I need to pass a property to a jar, like that: java -jar -Duser.language=en any.jar This line works fine in cmd.exe, but not in Powershell as it searches for another jar: Unable to ...

Windows batch file - check if file has been modified

I'm configuring a windows machine to continuously run a powerpoint presentation. The ppt file is located on a samba share (windows file sharing) and will be updated periodically. I need a way to make a batch file that will restart the ppt slide show if the file has been changed. The batch script will run on a a regular interval, and w...

How to loop through files and rename using PowerShell?

I would like to rename all the jpg files in a folder to uniform convention like Picture00000001.jpg where 00000001 is a counter. It would be a walk in the park in C# but I would think this is the kind of bread and butter stuff that PowerShell was made for. I'm guessing something like $files = ls *.jpg $i=0 foreach($f in $files) { Ren...

Extracting MBSA XML Data using Powershell

I'm trying to extract various information from Microsoft Security Baseline Analyser 2 results and helpfully found this script: http://fatbeards.blogspot.com/2009/01/powershell-mbsa-logs.html, however I also need a tally of CRITICAL updates, not just all updates as the script currently does. Critical updates are denoted with Severity="4"...

get a set of files that have been modified after a certain date

Does anyone have a handy powershell script that gets a set of files from TFS based on a modification date? I'd like to say "give me all the files in this folder (or subfolder) that were modified after X/Y/ZZZZ" and dump those files to a folder other than the folder they would normally go to. I know enough powershell to hack about and get...

Powershell: how to map a network drive with a different username/password

Background: Assume I use the following powershell script from my local machine to automatically map some network drives. $net = $(New-Object -ComObject WScript.Network); $net.MapNetworkDrive("p:", "\\papabox\files"); $net = $(New-Object -ComObject WScript.Network); $net.MapNetworkDrive("q:", "\\quebecbox\files"); ## problem -- this on...