Hi,
I am using switch parameters in my Powershell script in this fashion.
param(
[switch] $Word,
[switch] $Excel,
[switch] $powerpoint,
[switch] $v2007,
[switch] $v2010,
[switch] $x86,
[switch] $x64,
)
I am trying to figure out any neat way to have it more enum style.
As anyone might guess, I would want th...
Hi,
I am trying to create a file using powershell in a specific user context. E.g I have a user user01 on my local machine and I want to create a file in its context.
I am doing something like
New-Item c:\file.txt -Credential User01
It works but prompts me for password which I dont want it to. Is there any way I can accomplish this w...
What is the easiest way to convert a PSCustomObject to a Hashtable. It displays just like one with the splat operator, curly braces and what appear to be key value pairs. When I try to cast it to [Hashtable] it doesn't work. I also tried .toString() and the assigned variable says its a string but displays nothing - any ideas?
...
Hi guys. Using powershell I need to loop a series of pdf file and make some operation on them using pdftk. I'd like to know if exists some method to detect if pdf is encrypted or not. In this way, if the pdf is encrypted I don't work on it and my loop skips to the next file. Thanks for the attention.
edit. While I wait for some answer ...
Hello,
I am in need of a script or powershell command that will be able to determine the session id of a specific logged in user on remote machine, to be later used as parameter to the psexec -i execution of remote gui process on that session of that user on the remote machine.
So far i managed to use
psexec \\remoteMachine -u user -p...
Anyone have any ideas why the following code would produce an error, see additional comments after the function for more details
function callee ([Hashtable]$arg0) {
[Hashtable]$hashtable = @{}
$hashtable = $arg0
$hashtable.add('passed', $True)
# $hashtable ######## toggle this line
$typ...
Hello,
Working through Jerry Lee Ford Jr.'s Powershell 2.0 for the Absolute Beginner book. There's a lot of typographical errors in the code of the book that I've been able to work through and correct (great practice), but there's one I simply can't seem to figure out. Downloaded his stock code from the companion website, and his code i...
Hallo. If I run this code
$server = "."
$adsi = [ADSI]"WinNT://$server"
$adsi.psbase.children | where {$_.schemaClassName -match "user"} | select name, objectsid |Format-Table -auto
I get object sid in this form
1 5 0 0 0 0 0 5 21 0 0 0 138 93 63 151 163 49 215 2 60 164 164 50 236 3 0 0
I'd like to know if it's possible to convert ...
Hi!
We have customized the build process with a InvokeProcess action that runs a powershell script that deploys our sln.
Problem is that this script must be run under a given user (not the tfsbuild user).
How can we achive this?
Alternative 1: Make the InvokeProcess
run as a different user -
Alternative 2: Make the powershell script...
I want to open the Internet Explorer as a new Com Object with no Add-ons.
$ie=New-Object -comobject InternetExplorer.Application
How could I start the Internet Explorer without Add-ons?
...
In the script below I am calling a batch file to break mirroring between some dbs. The batch file has a user prompt to start the script but the PS script races right past it. When I call the batch file directly from the powershell console it works fine. How can I keep the script from move past the invoke command block with until the b...
I am trying to write a script that will delete the local profile of a test account. I am using the following line to return the SID of any account that starts with "test-"
PowerShell: $UserSID = (Get-WmiObject Win32_UserProfile | Where {$_.LocalPath -like '*\test-*'}).SID
Once I had the SID I used wmic to do the deletion but, I am not ...
I am trying to rename multiple files in windows using powershell.
And I want to rename replacing this pattern:
"123456-the_other_part_of_the_string".
Example:
409873-doc1.txt
378234-doc2.txt
1230-doc3.txt
Basically I want to crop the numbers + '-' thing.
...
Hi All,
I'd like to know if this is possible Using Powershell 2.0 to traverse directory and print files on the client installed printer ?
i got the below powershell script it works great over the shared network drive but how to actually modify and use it to query the content of WebDav folders and then print only the .PDF file extension...
Hi,
I'd like to search an xml doc (or rather Element with sub elements) for a string. It needs to be an exact match.
Here's a sample of the xml
<Car>
<Make value="German\Opel"/>
<Make value="German\Benz"/>
<Make value="Japanese\Nissan"/>
</Car>
...
Is ist possible to create a executable .exe file from a PowerShell Script?
...
Is it possible to create a string in a C# .exe and use this string in PowerShell?
...
I'm writing a script to create VMs, and obviously I would like to support the standard confirm/whatif semantics. However, if I have a number of machines to create, it would be good if I could differentiate between "Yes" and "Yes to All" so I don't necessarily have to reconfirm every machine.
$pscmdlet.ShouldProcess only returns a boole...
I'm retrieving the UnReadItemCount from several Outlook folders in a PowerShell WPK application. I create an Outlook.Application object, get the Session, and do a tour of the Folders, saving the Folder objects of interest in PowerShell variables. Then I retrieve the UnReadItemCounts from the saved Folder objects and display them in the...
I'm trying to write a PowerShell script that will do the following:
Executes a stored procedure or run a t-SQL command that returns a list of values.
Compares the data from step 1 to an existing file directory structure.
Creates directories for values in step 1 that are not in the existing directory structure.
Deletes directories for v...