I'm creating a PowerShell script that I'm going to execute using Start-Job. The job should continuously run in the background until I tell it to stop using Stop-Job. It should execute a SQL command on a timer with a specified duration and output the results to the jobs pipeline so I can retrieve them using Receive-Job.
Right now the j...
I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run commands remotely. So PS remoting is working between the local server and remote server.
But when I try to access a share on a 3rd server (di...
The Powershell team preaches using GUI on top of Powershell (GUI actions translated into Powershell commands in the background and executed).
I love the idea, specially b/c it would make my GUI scriptable (it's nice to click click and then see a trace window with all the cmdlets that I've executed).
My question is, do they provide some...
I am using Sandcastle Helpfile Builder to produce a helpfile (.chm). The project is a .shfbproj file, which is XML format, works with msbuild.
I want to automatically update the Footer text that appears in the generated .chm file. I use this snippet:
$newFooter = "<FooterText>MyProduct v1.2.3.4</FooterText>";
get-content -Encodin...
I'm trying to use PowerShell to create some backups, and then to copy these to a web folder (or, in other words, upload them to a WebDAV share).
At first I thought I'd do the WebDAV stuff from within PowerShell, but it seems this still requires a fair amount of "manual labour", ie: constructing HTTP requests. I then settled for creating...
Hi,
I'm totally new to powershell, and I need some help to get started.
What I need is to write a small script that backup a SQL database, but every time with different name (to keep the last 4-5 versions only).
Right now I have a BAT, which just launch osql with a sql script, as below
REM BAT file starts here
"C:\Program Files\Microsof...
The following line of PowerShell works with IIS 6 installed:
$service = New-Object System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC")
However, with IIS 7 it throws the following error unless the IIS 6 Management Compatibility role service is installed:
out-lineoutput : Exception retrieving member "ClassId2e4f51ef21dd47e...
I'm writing a C# Cmdlet that needs to get the value of a global script variable.
How do I do it?
I noticed that the Runspace has SessionStateProxy.GetVariable method.
Can I access the runspace from a C# Cmdlet?
Thanks!
...
How do I build a PowerShell snap-in to target PowerShell v1 and v2? Given that v1 and v2 can't be installed side by side how can I reference the appropriate assemblies and build against them?
Inevitably as things go on I'm going to be adding new PowerShell v2 specific features. So I'm going to need separate product builds targeting diff...
Is there a way to clear the $Error variable that tracks errors in a PowerShell session?
If so, how do you do it?
I have tried:
$error.clear
In the PowerShell ISE on Windows 7 and the $Error array is still populated.
...
PowerShell $OutputEncoding defaults to ASCII. PowerShell by default represents strings in Unicode. When I create scripts using the ISE, they are created in Unicode.
The following command sends text to a file in Unicode:
echo Testing > test.txt
When I push these files to GitHub, the code view chokes on them because they aren't UTF-8...
Hi,
I'm looking to use powershell to alter xml. I haven't been able with powershell to copy xml using the xpath. I can load the xml with the following:
$doc = new-object "System.Xml.XmlDocument"
$doc.Load("XmlPath.xml")
but after I get the XML I can't figure out how to list the xml with an xpath and create another xml file with wha...
Hi,
I have the following xml:
<?xml version="1.0" encoding="UTF-8"?>
<sections>
<section name="Options">
<item key="HLVersionControlWebServiceURL" value="http://www.personec.no/webservices/HLVersionControl/HLVersionControl.asmx" />
<item key="AltinnWebServiceURL" value="https://www.altinn.no/webservices/DataExchange.asmx" />
...
hi all, i wanted to automatically open the last opend files in ISE with posh script,
so i tryed to save filepaths of these files like the following.
$action = {
$psISE.CurrentPowerShellTab.Files | select -ExpandProperty FullPath | ? { Test-Path $_ } |
Set-Content -Encoding String -Path$PSHOME\psISElastOpenedFiles.txt
Set-Content -Enco...
Been having trouble with visual studio 2010
I've added reference to the project and double checked the
when i type using System.Management.Automation;
at the top of the file.
when I go to compile / build it ..
it says that the infamous are you missing an assembly reference.
any ideas?
...
Given the dir structure:
x\Code
x\Script\Backup.ps1
Backup.ps1 contains:
$BackupDirectoy = "..\Backup"
$CodeDirectory = "..\Code"
function BackupCurrentVersion()
{
New-Item $BackupDirectoy -type directory -force
Copy-Item $CodeDirectory -destination $BackupDirectory -recurse
}
BackupCurrentVersion
I'm doing somet...
I'm trying to do basic background jobs in PowerShell 2.0, and I'm seeing different things with start-job and invoke-command -asjob.
If I do this:
start-job -scriptblock {get-process}
I get a job object, but the child job (which is created automatically by start-job) always has a JobStateInfo of "NotStarted".
this, however, works as e...
Is it possible to detect that a specific user has an open session on a computer and to open a process in that session so that the application can be interacted with by the user using PowerShell remoting?
How would I go around detecting which users have sessions open on the machine and what their state is (active, idle, disconnected, etc...
This may be simple question, but I am new to Powershell and could not find a way to do it. Basically, I have to run a bat process if a specified file does not exist. The file name is in a patten like "mmddyyy.dat" in a folder, where mmddyyyy is today's month, day(0 prefix if < 10) and year. Pusdo codes would be something like this:
$Fi...
I have a file that looks like this:
a,1
b,2
c,3
a,4
b,5
c,6
(...repeat 1,000s of lines)
How can I transpose it into this?
a,b,c
1,2,3
4,5,6
Thanks
...