Group:  English: General ยป microsoft.public.windows.powershell

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Threads Replies Last Post
22 Pages: 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  
Remove empty folders
Looking for some help. I am scripting the move of files with a last access time older than 30 days and I would like to remove the folder that contains these files if that folder is empty after the files are moved. Here is what I have so far to move the files and maintain the folder structure. (Thanks to other posts on here) $now = get-Date get-ChildItem -recurse *|Where-Object{$_.LastAcces...
5 27.06.2007 04:30:04
Shortening string values
Hi there, I am new to PS and I would like to shorten the following string "WindowsDirectory : C:\Windows" to "C:\Windows". The string is assigned to variable but I need this variable to be "C: \Windows" so I can then manipulate this string to point to a folder under C:\Windows\System32 Could anybody tell me how to do this? thanks mimi ...
6 27.06.2007 02:35:19
powershell logon scripts
I'm trying to set up a powershell script as a logon script in group policy. The script resides in a policy directory, and so has a directory name in the path like {UID}. I can't get powershell to run the script. It gives an "Bad numeric constant" error and references a piece of the UID. Any ideas on how to get this script to run? Thanks, Andy Zirkel ...
11 26.06.2007 23:10:43
IP Addresses sort with Powershell
Hi, i wrote a Linux AWK Script, which sorts IP-Addresses. >>> #> cat ips | awk -F. '{printf("%03d.%03d.%03d.%03d\n", $1,$2,$3,$4)};' | sort -n -t "." | awk -F. '{printf("%d.%d.%d.%d\n", $1,$2,$3,$4)};' <<< The Windows Powershell is new for me. How can I make this with the Windows Powershell? My try: >>> PS C:\Users\Martin> get-content ips 124...
47 26.06.2007 21:28:00
Excel automation
I'm newbie to PowerShell and trying open my sample.xls file in obvious (to my mind) way: $xl=new-object -comObject Excel.Application $bk = $xl.Workbooks.Open('C:\TMP\sample.xls') But in vain! I got error message only. I found that this error was discussed in http://groups.google.ru/group/microsoft.public.windows.powershell/browse_thread/thread/c3210d944eb294d9/cbf5d22efb901147?hl=r...
4 26.06.2007 13:32:54
Invoke generic method from PowerShell
How does one invoke a generic method from PowerShell? For example, let's say I have an assembly MyAssembly.dll with a public class MyClass. MyClass has (wait for it) MyGenericMethod<T>(). Let's say in PowerShell I load the assembly and get an instance of MyClass: [System.Reflection.Assembly]::LoadFrom("MyAssembly.dll") $MyClassInstance = New-Object MyAssembly.MyClass How do I ...
8 25.06.2007 19:33:51
Supplying mandatory parameters question
I have written a couple of cmdlets. One of them takes as input object' created by another one and in case I don't specify mandatory parameter I cannot specify variables on command promt. Why is it so? Is it a usual behaviour? Like this: $1 = get-myobject param1 $2 = get-myobject param2 compare-myobject cmdlet compare-myobject at command pipeline position 1 Supply values for the foll...
3 25.06.2007 18:09:00
PowerTab Security Warnings?
I couldn't find an answer on MOW's website so I thought I'd see if anyone here knew how to get around this - every time I start a PS session I'm prompted to either [D] Do not run [R] Run once or [S] Suspend all the PowerTab scripts Is that expected behavior or am I missing something? Thanks, Mesan ...
3 25.06.2007 16:54:16
BinaryFormatter problem
I faced some problem with BinaryFormatter. Deserialize method doesn't work when I run it from PowerShell Cmdlet, while it works normally in test application. I have found only one solution - place dll in GAC, is it correct way? Here is example. It fails on deserialize method telling that it cannot load assembly. [Serializable] public class Test { private int num; pub...
4 25.06.2007 13:17:00
Optimizing PS Script to List directories
Hey, If I run the command below it will list all directories that have the word "Data" in the path, if I run it locally it's real quick and can find all the paths within seconds, but I need to run it on all our remote file servers and it is dog slow and was wondering if anyone knew anyway to optimise it? get-childitem \\server\e$ "Data" -recurse | Where-Object {$_.mode - match "d" } | ...
6 25.06.2007 01:24:19
Accessing "System Information"
Is there a programmatic way to access "System Information" as the GUI does? If it's done purely via WMI, is there a document that specifies which WMI objects were aggregated? Obviously, powershell is the way to script these days....
5 23.06.2007 15:26:20
parsing commands from xml documents
I have a small script file that I am writing. It downloads an xml file from the internet and parses it using get-content. I would like to be able to have it execute certain commands out of the document. i.e. $file.data.activedirectory.command is a text element in the xml file that contains dsadd ou ou=..... (or write-host or any other command for that matter). When I call $file.data.... ...
8 22.06.2007 20:07:01
Any command like the tail -f from unix/linux to open log-files
Hey Guys, is there any command in Windows Powershell like the "tail -f <filename>" command from unix/linux to open a log-file once an see the changes directly? thanks for answers! regards florian ...
12 22.06.2007 20:02:02
Generic Failure on DFS WMI providers
Hi All, I want to do some things with the DFS WMI providers in Server 2003. Looking at them through Powershell, I can't seem to access them. gwmi -computer server1 -class "win32_dfsnode" Get-WmiObject : Generic failure At line:1 char:5 + gwmi <<<< -computer server1 -class "win32_dfsnode" Same goes for win32_dfstarget and win32_dfsnodetarget. Other classes seem to retur...
5 22.06.2007 19:35:15
how do i get locales in sync between powershell and dotnet
on a german pc: PS C:\Temp> [double]::Parse("12.3") 123 PS C:\Temp> [double]"12.3" 12,3 extremely unpleasant to debug such errors ... Harald...
5 22.06.2007 17:40:48
how to get rid of line wrapping in powershell
PS C:\Temp> '-' * 200 >a.txt halfway correctly generates a line of 200 - and incorrectly adds an additional newline C:\Temp>powershell -command '-' * 200 >a.txt wraps the line into two lines. How can I get rid of these behaviors Harald ...
5 22.06.2007 17:22:19
ANN: PowerShell support added to JAMS
We've just released a beta version of JAMS which includes PowerShell support. JAMS is an enterprise grade task scheduler. Our PowerShell support includes a number of cmdlets, a provider and the ability to execute PowerShell scripts. You read more here: http://www.mvpsi.com/PowerShell.aspx You can download the free Developer's Edition here: http://www.mvpsi.com/Free.aspx We welco...
1 22.06.2007 16:05:08
PSCX - Send-SmtpMail probs
I'm tyring to use the Send-SmtpMail community extension CmdLet with no joy. No matter what options I give and I get the same error: Send-SmtpMail : Failure sending mail. At line:1 char:14 + Send-SmtpMail <<<< <I'm using -To, -From, -SmtpHost, -Subject, -Body: all param values are enclosed in quotes. Using -anonymous or -credential has no effect> ideas? Cheers, n...
5 22.06.2007 15:55:45
Search and replace - regex problem
Hi I want to replace a line in file MySource.cpp as follows. Original line: // HOST COMPILER: ADI VisualDSP++ 4.0 New line: // HOST COMPILER: ADI VisualDSP++ 4.5 I tried the following command: PS C:\Transfer> (gc MySource.cpp) -replace "VisualDSP++ 4.0","VisualDSP ++ 4.5" | sc MySource.cpp but got the following error: Invalid regular expression pattern: VisualD...
8 22.06.2007 03:20:47
how do I keep powershells current directory and dotnets current directory in sync
System.IO.FileInfo and every dotnet function has a current directory, that is different from what powershell thinks is the current directory. [system.Environment]::CurrentDirectory = (convert-path ".") puts it in sync once, but after every cd everything is wrong again Calling Convert-Path before using a dotnet function is extremely tedious and error prone. Harald ...
2 21.06.2007 22:10:00
Edit Text File and Save
I have a situation where I need to add " to the beginning of the text in a ..csv file that is output by Sql Server BCP. I've tried the following but for some reason the file size goes down instead of up and the file won't open after it's written. Anyone have an idea? $FileContents = Get-Content -Path C:\Production.csv $Quotes = '"' $FileContents = $Quotes + $FileContents $TodayDate =...
5 21.06.2007 17:36:00
Need advice for Cmdlet verb selection
I've create cmdlet, that executes sql script on database server. Now I need to name it according to microsoft guidelines. It is required to choose verb from predefined, but I cannot find any suitable. Could you advise me the verb name from predefined. Will it be correct if I'll choose verb for my cmdlet not from the list? I expect something like execute, deploy. But choose only these: s...
6 21.06.2007 12:50:00
stsadm.exe -createsite does not work well
System: Server 2003 Windows SharePoint Services 3.0 _____________ Hi NG, the command stsadm.exe -o createsite -url <url> -ownerlogin <login> -owneremail <mail> -sitetemplate <template> does not work. i added a template with stsadm.exe -addtemplate <name> to the global template gallery and wanted to use it when creating a site... but visiting the just c...
2 21.06.2007 12:05:13
LABS: Writing PowerShell cmdlets and integrating with MMC
These labs just became public from Microsoft, they are good starting points for anyone wanting to develop... http://blogs.msdn.com/daiken/archive/2007/06/20/windows-powershell-and-microsoft-management-console-3-0-quick-start-labs.aspx Marco...
1 21.06.2007 11:51:31
collection sms 2003
i need to move query based subcollections from one parent to another in sms 2003 the thought is to copy the existing collection properties, name query, to 2 variables $colname $colquery delete the existing collection create the new collection using $colname $colquery under its new parent $colItems = Get-WmiObject -class "SMS_Collection" -namespace "\root\sms\site_p01" -computername ...
1 21.06.2007 09:49:01
22 Pages: 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net