I am using ManagementClass.GetStronglyTypedClassCode to get a reference to CodeTypeDeclaration instance. I would like to change the generated class name and this method doesn't allow for this (as far as I can tell). I have tried to change the CodeTypeDeclaration.Name property, but this doesn't change constructor names etc, so the C# comp...
I am creating a powershell script as a background job using start-job which then logs it's output using start-transcript. Below is the code of both:
a
start-job -filepath ./b.ps1 -ArgumentList 'test.txt'
wait-job *
b
param([parameter(Mandatory = $true)][string]$logfile)
Set-PSDebug -Strict
$ErrorActionPreference = 'Stop'
start-tran...
Is there a way to tell if a disk has a GPT or an MBR partition with powershell?
...
Hello all,
I have created a virtual machine. Now I am trying to launch it using Powershell. I have searched all over the internet for any details on how to do that. This is the only code i found...
----------------------
$vBox = New-Object -ComObject VirtualBox.VirtualBox
$vBox | Get-Member *
$vBox.Machines
$vBox.CreateMachine()
--...
Hi.
I would like to populate DataGrid with XML data stored in variable.
Below I have working example of populating DataGrid.
$grid = New-Object System.Windows.Forms.DataGrid
$array = New-Object System.Collections.ArrayList
foreach ($e in $(Get-Process | Select Name,Company)) { $array.Add($e) }
$grid.DataSource = $array
How can I do...
I have a script that creates two groups, a hand full of folders, and sets permissions on those folders. In my testing environment all of these processes work without issue but in my production environment I run into a problem. Setting the permissions on the folders fail since the groups I created have not replicated through all 8 of my d...
Powershell tab expansion functions take 2 parameters, the line so far, and the "current word". The function should return a replacement for the current word.
From experiment, it seems to me that the current word is passed to the function without any quotes, and the returned word is inserted into the line with the same quoting as the ori...
I have this powershell code.
$securityidentifier = new-object security.principal.securityidentifier $sid
$user = ( $securityidentifier.translate( [security.principal.ntaccount] ) )
This code works only on a computer which is in the same domain as the user whose SID I would like to translate to ntaccount.
Is it possible to translate ...
I'm trying to run MSTest.exe from C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE. What's more, I'm taking all of the assemblies in my current directory and setting them as separate /testcontainer arguments. I cannot figure out how to do this without Powershell complaining.
$CurrentDirectory = [IO.Directory]::GetCurrentD...
Trying to have "dir" command that displays size of the sub folders and files.
After googling "powershell directory size", I found thew two useful links
Determining the Size of a Folder http://technet.microsoft.com/en-us/library/ff730945.aspx
PowerShell Script to Get a Directory Total Size http://stackoverflow.com/questions/809014/pow...
This is my current PowerShell code:
connect-QADService -service 'view.domain.com' -Credential 'MyDomain\Administrator'
$AllVMs= ( get-QADObject -SearchRoot 'vdi.vmware.int/Servers' -type pae-VM -IncludedProperties ipHostNumber,pae-SIDString )
How it can be rewrited in C# (.net 3.5) ?
...
Hi all,
I'm working on a automated script for deploying sharepoint projects. I'm using a sandbox level webtemplate that must be applied when de site is created. I had a lot of troubles doing that because it seems like sharepoint caches the list of webtemplates and get-spwebtemplate doens't find the new added one. The way I made it work i...
I'm writing a C# class that runs a Process (REG) to export registry keys. REG requires that you specify a filename to export to but I would rather have the output of REG directed to the standard output so I can capture it directly in my C# code (using Process.StandardOutput). Is there a way in PowerShell to specify the standard output ...
I need to read a file on a remote server, however I dont have permissions to do so. If I use another account with elevated rights, I can. I would like to run the script from anywhere with the credentials built into the script (accepting the risks).
...
I asked this on ServerFault, but didn't get any reply's, I know it's command line, but they should still be able to answer it, anyone here have any idea's?
I've ran the following (task description):
> Add-PsSnapin Microsoft.SharePoint.Powershell
> Backup-SPFarm -Directory E:\Backups -BackupMethod Full
But get this error:
Backup-SPFa...
I need a way to "cut the power" of my WLan device.
Currently I use a PowerShell script to disable the network interface, but I'm not sure if this also really stops the device from scanning and so on. If its possible I'd like to implement this with C++ or C# via WinAPI/WMI.
Current PowerShell Script:
$WLanDeviceID = 11
$WLanAdapter = g...
I obviously don't know what I'm doing.
I have finally got this PowerShell command to work. But I can't figure out why it works.
My concern is the final "" chars:
&"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" `
-verb:sync `
-source:contentPath="$build_directory\deploy" `
-dest:contentPath="$server_temp_dire...
Hi,
I've writing some Exchange 2010 Unified Messaging automation scripts. I'm trying to automate the assoication of UM dial plans to UM Servers. The powershell command is :
[PS] E:\Scripts>Set-UmServer -id Exchange01 -DialPlans "test1", "test2"
When I try the following scripting solution:
[PS] E:\Scripts>$str = "`"test1`", `"test2`...
I am trying to export the content from a staging server and import it into a development machine. I've tried to do this with Backup-SPSite -Identity http://staging -Path c:/export.bin on staging and Restore-SPSite -Identity http://devmachine -Path c:/export.bin -Force on development, but after I do this, some assets (e.g. images in webp...
I get this error message when I run the Powershell script at the bottom:
Exception calling "EnumScript" with "1" argument(s): "Script failed for Table 'dbo.Product'. "
At :line:48 char:35
+ foreach ($s in $scripter.EnumScript <<<< ($tbl)) { write-host $s }
However, when I comment out the output_file line
#$output_file="C:\Product.sq...