|
Dir with Color
Hello!
I try to create a function like the Linux ls. To do a ls, I use
Get-ChildItem | Format-Wide -Autosize.
The only distinction is that Directory is in "[ ]". But I like to change
color (Red for exe, Blue for Directory, etc.)
Any idea? I've found a function sample using $Host.ui.rawui.foregroundcolor
= Color (or something like that) but this seems not to work with the
Format-Wide...
|
20 |
12.07.2007 20:48:12 |
|
using where-object and -contains operation
I'm trying to use the following powershell command, but keep getting back
zero results. The command will run, but just not return any values. I'd like
to find all the mailboxes where the name has "bill" in it.
get-mailbox -ResultSize Unlimited | where-object {$_.Name -contains "bill"}
if I use the following command I get results (even if it is just one)
get-mailbox -ResultSize Unlimit...
|
5 |
12.07.2007 20:46:02 |
|
how to add Unix line breaks
Hi.
So, is it possible to use set-content (or something) to add Unix line breaks
to a text file?
--
Antti
...
|
3 |
12.07.2007 19:10:06 |
|
Win32_Process create method
Hi there,
In one of my scripts I'm trying to create processes on a remote server
using the WMI Win32_Process class.
I'm running into some inconsistenties. When creating the process in
all cases I get Exitcode 0, so the process is created. However some of
my commands don't seem to be executed.
When I try to fire up a vbscript using either "cscript c:\temp
\script.vbs" or "cmd.exe /c cscrip...
|
3 |
12.07.2007 16:39:39 |
|
Suggestion: 1 new operator (well, maybe 6...)
Today I noticed that one important operator is missing in PowerShell: -in
Programming languages such as Pascal/Delphi use the "in" operator to test if
an object is contained in a set or array.
I know that we already have the -contains operator that can do basically the
same thing just with inverted syntax:
PS> 1..10 -contains 5
$true
vs.
PS> 5 -in 1..10
$true
So h...
|
11 |
12.07.2007 16:34:48 |
|
scheduled task output is truncated
I have a powershell script run as a scheduled task - as such CMD.EXE is
used to launch psh. The script attaches a table of data to
Send-SmtpMail - but when it does this running under cmd.exe the table
output is truncated to the size of the command window.
I don't seem to be able to use a modified shortcut to CMD.EXE in order
to change the layout to a suitable size and I can't find refer...
|
5 |
12.07.2007 14:55:00 |
|
win32_process type name not found in system.management.managementc
I am new to powershell and was trying to use powershell to install/uninstall
services on a remote machine. the command i was using to create a
win32_process is:
PS C:\> $mc = new-object system.management.managementclass
\root\cimv2:win32_process
This command was working fine untill earlier today and i was messing around.
I found out that i executed this line:
PS C:\> $mc.de...
|
5 |
12.07.2007 13:52:02 |
|
Using COM in PS
Hello,
When I try to get the list of the printers installed on the server using in
ASP.NET I get an empty list. The only solution is to use LoadProfile (this is
becauses printers are in USER part of the registry). When I want to print a
..doc document I need the same + impersonation and desktop (duplicate token
and logonuser).
If I use COM Word object in a PS scriptlet called by ASP....
|
1 |
12.07.2007 13:34:04 |
|
$AdminSessionADSettings when running Exchange script from batch
Hi there,
I've written several scripts which will be called from a batch file
using
PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange
Server\Bin\ExShell.psc1" -Command "....."
These scripts contain the statement:
$AdminSessionADSettings.ViewEntireForest = $true
When I start the batchfile it fails with:
Property 'ViewEntireForest' cannot be found on this object; m...
|
1 |
12.07.2007 13:19:23 |
|
LastWriteTime and Locating the drive letter of a flash drive.
Part 1
Is the Get-ChildItem property 'lastwritetime' equivalent to explorer's
'Date Modified'?
Part 2
I am running Windows XP. I back up my files to a flash drive. My
current 'cmd' script blindly erases the files from my flash drive and
then 'copies' my working set from my hard drive to the flash drive.
I am writing a PS script that compares the 'lastwritetime' date
between the two med...
|
5 |
12.07.2007 10:47:12 |
|
output .ps1 script to text file
I have the following script that list installed hotfixes. My problem is right
now it uses the write-host to show it on screen. I am looking for assistance
on how it can be modified to either write to screen and text file or just a
text file.
$strComputer = "."
$colItems = get-wmiobject -class "Win32_QuickFixEngineering" -namespace
"root\CIMV2" `
-computername $strComputer
foreach...
|
3 |
11.07.2007 22:30:09 |
|
win32_product uninstall method
I am trying to learn how to call WMI methods in PowerShell, in this case the
win32_product Uninstall method. So far, none of the information I've found
has worked. I've tried 3 methods (I have substituted programname for the
desired program):
1)
$pc = Get-WmiObject -query "SELECT * FROM Meta_Class WHERE
__Class='Win32_Product'"
$pc.uninstall("programname")
this one returns the erro...
|
3 |
11.07.2007 21:49:52 |
|
Powershell Analyzer and Powershell IDE
Now I am totally confused. I Powershell IDE still a product or has
that team merged with the Powershell Analyzer people?
Fred J.
...
|
6 |
11.07.2007 21:02:04 |
|
list open files in a shared folder
is it possible to get a listing of all open files in a shared folder?...
|
2 |
11.07.2007 20:48:04 |
|
out-WPFGrid cmdlet
FYI
"I’ve created a PowerShell CmdLet to show pipeline data in a WPF based
Grid."
Source and all.
http://blog.lab49.com/archives/1230...
|
3 |
11.07.2007 16:31:12 |
|
Term Server Printing
Hi all--
I have a client running a Window 2003 Terminal Server. One of the apps
running on the server requires printing to LPT2. I need to write a script
that will perform the following:
1. Determine the default printer (as setup by the term serv)
2. Share the default printer using a standard naming convention
3. Map LPT2 to the newly-created share name (similar to net use lpt2:
...
|
4 |
11.07.2007 14:56:15 |
|
Yield to the OS
Hi
If I have a while loop that simply holds execution until a command has
completed how do I stop it frying the processor?
What I am actually doing is mapping a network drive and I want to ensure
this has finished before continuing e.g.
$net = $(New-Object -Com WScript.Network)
ForEach ($hst in $hstLst)
{
$pingStatus = gwmi Win32_PingStatus -Filter "Address='$Hst'"
If($pingStat...
|
4 |
11.07.2007 08:38:01 |
|
Problems creating pure text files
Dear Sir,
I used the following to create text files for testing:
1..3 | %{ "This is file $_" > "File$_.txt"}
It seemed that the files created are not pure text files. There is something
appending to the end.
When I tried the following:
add-content file?.txt -value (get-date)
I got a bunch of Question Marks appended to the file instead of the date
value.
Kindly help.
...
|
3 |
11.07.2007 06:38:02 |
|
Office Service Pack via PowerShell (WMI)
I can retrieve the OS service pack via WMI with Powershell without a problem.
However, finding the Service Pack for Office is proving to be a bit more
difficult. I need to script this out and so far, have not been able to do so.
Any ideas?
Thanks!
Wes...
|
3 |
11.07.2007 02:00:00 |
|
Calculate Printer Page Count Per User
I have a script that pulls all print events from the main print server and
archive them. Now I would like to take those archives and come up with a
total page count for each user. Initially I am only looking to do this for
one particular printer.
I have a powershell function that returns the username and the page count
for that particular print job from the printer I want to report on...
|
4 |
10.07.2007 20:34:15 |
|
missing help file Error_handling
What's the best way to report this to Microsoft? I waned to find help
on trap and by searching the Powershell Graphical Help file I was able
to find a reference to it in the about_execution_environment help file
but the referenced file (Error_handling) doesn't exist.
about_Execution_environment
SHORT DESCRIPTION
Factors that affect how commands run
LONG DESCRIPTION
The Win...
|
3 |
10.07.2007 16:53:33 |
|
Variable assignment gone bad
I am sure that in six months I will think this was a simple question. Right
now it just confuses me. I tried to assign the values from a hash to what I
expected would be an array. Instead I got something completly different, and
I don't seem to be able to access the values stored in this variable. The
same trick works for keys, but it is called a
System.Collections.Hashtable+KeyColle...
|
7 |
10.07.2007 15:22:03 |
|
dos command in powershell
Hi there, as suggested to me a few days ago, i'm trying to make a "net
use \\printerserver" into my ps1 scripts, but don't succeed; my
command line i try to use is
$chaine="net view \\"+$server
$pi=&{$chaine}
i've tried
$chaine="net view \\"+$server
$pi=&($chaine)
$pi
too but nothing happens... $pi stays equal to $null; why ?
if it is not so that i have to do, how could i execu...
|
3 |
10.07.2007 11:49:14 |
|
"Edit" in the context menu for sp1 files
I am using Windows PowerShell in Vista Ultimate x64.
I would expect the context menu for sp1 files to have both OPEN (=run) and
EDIT (with Notepad) items. It only has OPEN.
How could I open the file for edit other than dragging it to the Notepad
icon on the desktop?
Thanks,
...
|
3 |
10.07.2007 10:36:07 |
|
Export-csv and non-English letters
Hi!
I`m using Quest`s PowerShell commands for Active Directory
(http://www.quest.com/activeroles-server/arms.aspx).
I`ve exported users in an OU to import them in another domain using;
Get-QADUser -SearchRoot 'Domain.local\myOU'| select
name,samaccountname,userprincipalname,parentcontainer | Expor
t-Csv c:\export\users.csv
But some of the users have some of the three Norwegian lett...
|
3 |
10.07.2007 03:36:00 |