|
Add include/exclude property support to Export-Csv
To have a subset of object properties exported to a csv file we need to select
the properties first with select-object and then pipe to export-csv:
dir | select name,length | export-csv c:\files.csv
If export-csv had a parameter to include/exclude properties then we could
save an extra piping overhead. For example:
dir | export-csv c:\files.csv -IncludeProperty name,length
...
|
1 |
12/26/2008 3:01:19 PM |
|
How to retrieve a generic method with GetMethod (reflection) ?
How to retrieve a generic method with GetMethod ?
Code:
--------------------
#public static void Sort<T>( T[] array, Comparison<T> comparison)
[System.Reflection.MethodInfo] $Methode = [System.Array].GetMethod("Sort",@([System.Array],[System.Comparison``1]) )
$Methode -eq $null
# return True
#OK : [System.Array].GetMethod("Sort",@([System.Array],[System.int32],[sys...
|
5 |
12/25/2008 12:20:52 PM |
|
Visio 2003 Scripting? Org chart job
I have a powershell script that pulls out Org Chart data from our AD
and saves it as an Excel file. Now I am trying to automate the Org
Chart Wizard in Visio 2003. I am not having any luck in finding
anything so far. When I do this manually. Sometimes it seems to keep
the pages and how many subordinates should be shown.
Any pointers as to which way to go? Thanks.
Merry Christmas, Happy H...
|
3 |
12/24/2008 10:57:18 PM |
|
Add-Member question
---------------------------------------------test.ps1----------------------------------------------
$global:foo = gi $PSHOME\powershell.exe
$global:foo = $global:foo |
Add-Member -Name CommandType -MemberType 'NoteProperty' -Value "foo"
-PassThru |
Add-Member -Name Definition -MemberType 'NoteProperty' -Value "foo" -PassThru
$global:var = gi $PSHOME\powershell.exe
$_var = gv var -Scope...
|
8 |
12/24/2008 9:48:06 PM |
|
Get-Process - How to get file paths as shown in "TList /c"
Am trying to retrieve the file path of processes as shown with tlist command.
Anyone know how this can be done with powershell?
Thanks,
--
alan...
|
13 |
12/24/2008 4:54:01 PM |
|
Checking FTP logs for SSL usage
Using the two demo files from
http://blogs.msdn.com/mubashirk/archive/2008/12/19/ftp-over-ssl-how-to-check-in-ftp-logs.aspx
where each file's data is saved
into a separate file, IisFtp1.log and
IisFtp2.log, use Microsoft's (local
or remote) data parser, Log Parser,
within the Windows admin's automation
tool, powershell.exe, to check on
SSL usage with FTP. (Remember,
in real life the...
|
1 |
12/24/2008 4:38:36 PM |
|
Manipulating members of a COM+ container in powershell
Hello,
I'd like to iterate through all the members of a COM+ application in Windows
powershell and set all their "Allow IIS intrinsic properties" to true. I
haven't seen anything about how to work with COM+ in powershell, but I'm sure
it must be possible.
-Eric...
|
3 |
12/24/2008 2:39:01 PM |
|
Win32_DesktopMonitor WMI class missing
[code]
gwmi -query "SELECT * FROM Win32_DesktopMonitor"
[/code]
According to Pro Windows PowerShell (ISBN: 978-1-59059-940-2) on pp.
413, I should have the following output:-
....
ScreenHeight : 900
ScreenWidth : 1440
....
What could have caused this problem?
Cheers....
|
4 |
12/24/2008 12:50:57 PM |
|
Register-ObjectEvent CTP3
In the script below I see the Console.WriteLine happen.
I expecte the Get-Event would work but returns null.
It'd be really cool too if in the ISE, put a breakpoint on the embeded
C# code (or other .Net Lang) and it gave you a debug context for it.
Probably way too hard.
Running the C# from VS ID, launching PoSh, set a breakpoint on
Talked(this, new EventArgs());
I can see PowerShe...
|
1 |
12/24/2008 1:04:01 AM |
|
using get-wmiobject Win32_logicaldisk
I am trying to get the drives for remote pc. When I run this on local pc it
works fine. When I run it for a remote pc it only returns C and D drives, no
mapped drives. The drives are mapped in a login script. Would that make a
difference? This seems pretty simple, but I can't seem to work it out. Any
help is greatly appreciated.
get-wmiobject -computer PCname win32_logicaldisk | s...
|
7 |
12/23/2008 11:25:11 PM |
|
Charting - Doughnut
Mmm need to chart PowerShell obtained
data in a doughnut (or a pie) chart with
perhaps other graphics or text?
$random = new-object System.Random
# Load chart assembly.
[reflection.assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
# Create some chart elements.
$chart1 = new-object
System.Windows.Forms.DataVisualization.Charting.Chart
$chart1.BackColor = "Whe...
|
1 |
12/23/2008 11:04:13 PM |
|
Get-Children -path \\server\share fails
Specifically it is failing on \\live.sysinternals.com\tools with the
message that the path does not exist. I am new to PS and don't really know
how to proceed from there: the diagnostic is not very informative. All I
can say is that I can see that share using a web browser and that the
firewall does not seem to block PS.
Thanks,
-- O.L....
|
3 |
12/23/2008 10:41:14 PM |
|
comparing a string that contains a parenthesis
Hi, I'm having trouble finding documentation on this.
For example, if a string value is "Intel(R) Pentium(R) 4 CPU 2.00GHz",
using -match " 4 CPU 2.00" gives True, but
using -match ") 4 CPU 2.00" gives False, and
using -match "`) 4 CPU 2.00" gives False, and
using -match ') 4 CPU 2.00' gives False.
How do you compare a string if it contains a parenthesis?
Thx....
|
5 |
12/23/2008 9:33:11 PM |
|
Trap bug of feature?
My Xmlfile:
<xml>
<test123>test</test>
</xml>
My Code:
$lol = $true
[xml]$in = get-content ./test.xml
trap [Exception]{
write-host $_.Exception.Message;
$lol = $false
continue;
}
if($lol){write-host "hello world"}
My Code 2:
$Global:lol = $true
[xml]$in = get-content ./test.xml
trap [Exception]{
write-host $_.Exception.Message;
$Global:lol = $false
continue;
}
if($Global...
|
2 |
12/23/2008 8:39:23 PM |
|
CTP3: is Set-Content -LiteralPath broken?
I have just got CTP3.
Am I missing something? Set-Content with -LiteralPath is not working
for me. If I remove -LiteralPath, or use -Path then it works as
expected. With -LiteralPath just nothing happens....
|
3 |
12/23/2008 3:05:46 PM |
|
Using a variable from within a function
Having trouble with this - would like to re-use the same function to step
through a number of input boxes before writing to a file - however, the
function drops out afer obtaining the variable ($x) and does not allow me to
re-use it - I'm sure there is a simple solution but have been unable to find
it - trying to add the variable $x to the input file:
$date = ( get-date ).ToString('yyyy...
|
3 |
12/23/2008 2:43:13 PM |
|
[ANNOUNCE] PowerShell v2 CTP3!
http://www.microsoft.com/downloads/details.aspx?familyid=c913aeab-d7b4-4bb1-a958-ee6d7fe307bc&displaylang=en&tm
I knew Santa and his elves wouldn't let us down! ;-)
Marco
--
*Microsoft MVP - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition (due December
15th, 2008)
*PowerShell Co-Community Director - ht...
|
2 |
12/23/2008 11:26:50 AM |
|
List AD user with or without an Exchange Mailbox
so far I got this
GET-QADuser | Get-mailbox
I got a red message when the user doesn't have a mailbox associated
I'm also looking to delete a mailbox without deleting the AD user, I
go this command Remove-mailbox, but it does delete the mailbox and the
AD user associated
...
|
7 |
12/23/2008 8:26:03 AM |
|
Using the FlagsAttribute Attribute
I'm playing with a script that parses strings to Integers using
system.int32.parse() and using the system.globalization.numbersytles
enum (see
http://msdn.microsoft.com/en-us/library/system.globalization.numberstyles
..aspx).
With C# you can specify a FlagsAttribute attribute to, in effect,
convert the enum values into bit patterns that you can add up. Using
this attribute, [system...
|
5 |
12/23/2008 3:06:47 AM |
|
Charting the highest and lowest values
Mmm need to chart PowerShell obtained
data showing the highest (in green), the
lowest (in red) and all the in between (in
yellow) values?
$random = new-object System.Random
# Load chart assembly.
[reflection.assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
# Create some chart elements.
$chart1 = new-object
System.Windows.Forms.DataVisualization.Charting.Cha...
|
2 |
12/23/2008 12:04:14 AM |
|
Powershell msiexec
when i try to install a program in powershell using msiexec the command fails
if any of the optional properties has a space. The command fails if i
include the property value in quotation marks. The command succeeds in the
normal windows command prompt.
i am using powershell 2.0 CTP...
|
3 |
12/22/2008 11:29:57 PM |
|
notify users of expiring password?
I have a number of Mac users who only occasionally log into our Windows
domain file server. Frequently their passwords will expire without them
having been notified, and they'll come to me in order to have their password
reset.
I would like to figure out a way for users to be notified via e-mail that
their network password is about to expire in x number of days. Any ideas?
Thanks...
|
3 |
12/22/2008 11:13:38 PM |
|
Remove XML element from a node
I have a XML file and I would like to remove an element. The element I would
like to remove "Version". I managed to figure out how to change the value
and remove the parent (NRCS). It would be easy enough to parse the file and
remove the line but I figure there has to be a proper way.
<JEDevParams>
<Login>
<AMServer></AMServer>
<NRCSServer></NRC...
|
5 |
12/22/2008 10:58:19 PM |
|
Variable assignment and clone or objet reference
Hi,
I try to anderstand how variable assignment works.
Indeed, when you assigne string or int value to a variable and after the
variable to another, both of them are separate (change one don't affecte this
other)
But, if you try that with an other object (ex : psobjet) then if you change
one, this other is affect.
Then in one case there is a cloning of objet and in other case there is ...
|
4 |
12/22/2008 10:24:34 PM |
|
Charting - High or Low
Mmm need to chart PowerShell obtained
data - like on or off, high or low (and etc.)
with colors, like with red and green?
$random = new-object System.Random
# Load chart assembly.
[reflection.assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
# Create some chart elements.
$chart1 = new-object
System.Windows.Forms.DataVisualization.Charting.Chart
$chart1.BackC...
|
1 |
12/22/2008 9:29:07 PM |