Click here to Skip to main content
15,891,657 members
Everything / Programming Languages / PowerShell

PowerShell

PowerShell

Great Reads

by The Ænema
This article will teach you how to create an amazing, clean and smooth WPF/Winform UI for your native application without using any complex, unsafe, ActiveXish methods, etc.
by Daniel Miller
This article describes the C# implementation for a high-performance user/role security principal hierarchy.
by Jo_vb.net
This article and the demo are about getting started using the MVVM Toolkit and some self-created interfaces / services for MessageBox and some dialogs.
by Christian Vos
How to use Microsoft Unity Interception as a solution for cross cutting concerns in a .NET application

Latest Articles

by Federico Di Marco
A tool which creates one or more Powershell scripts which in turn recreate one or more binary files
by Wessel Beulink
Azure spearheads cloud evolution, Azure Automation Runbooks manage hybrid/SOC environments effectively
by Federico Di Marco
How to enable Bitlocker hardware encryption on self encrypting drives
by Federico Di Marco
Create quickly VPN connections in Windows according to a XML configuration file

All Articles

Sort by Updated

PowerShell 

15 Oct 2018 by #realJSOP
This CP article might help: Compiling C# Code at Runtime[^] You could essentially create a CSharpScript app that loads a text file that contains C# "script" code and compile that script at runtime. You could also write pre-compiled plugins for your script runner app, and specify the DLL...
2 Jun 2020 by .Net Core Developer
This post will help you to Create, View & Delete your own Event "Source" using PowerShell.
9 Apr 2023 by 0x01AA
OnStart and OnStop are not events the .NET object System.ServiceProcess.ServiceBase does expose. These are virtual Methods you can ovveride in case you derive from ServiceBase. For more infromation please read this: Register-ObjectEvent...
22 Dec 2015 by 2irfanshaikh
Use SharePoint Commandlets in Windows PowerShell ISE
21 Feb 2014 by @BangIndia
I am using c# in windows xp machine. I am try to execute the commanelet "Get-WdsClient"(which is avaiable only in 2012 server when wds service enabled machine).My exe is excutingall the comments which is avaialble in my machine.. but when i try to execute the Get-WdsClient comment its...
2 Mar 2014 by @BangIndia
I am using vs 2008 in windows server 2012.code : InitialSessionState iss = InitialSessionState.CreateDefault(); RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace =...
8 Sep 2014 by _Asif_
Check this!Reading Device Manager's Property Fields in Windows 7/8[^]
15 Apr 2016 by Aakash Kumar Morya
I am trying to create a new distribution list using exchange server command "New-DistributionGroup"When i am entering duplicate alias name then it is allowing me to create the new distribution list. While when i try to create the distribution list from the Exchange Server UI in Office 365...
22 Aug 2014 by Abhi - Texas
PowerShell script which allows to get the sizing of any URLs for SharePoint 2010
30 Nov 2011 by Abhijit Babar
I have created Form in Powershell 1.0. It contain 50 controls like Label, Radio Button, Edit Box. I have to apply the specific font to all these controls. Now i am applying font to individual control. I want to apply font to all control in one time.
6 Jan 2013 by Adel Refaat
How to convert multiple SharePoint 2010 projects to SharePoint 2013
20 Jun 2021 by Aditya-Sharma0712
How to set classification label to an Excel/Word/PDF file at the time of its creation during runtime programmatically
8 Aug 2017 by Afzaal Ahmad Zeeshan, Iqra Ali
Since I wrote an article previously, I had been asked on various occasions to share the code on Yahoo! or Bing, etc. I wanted to write an article, with the code, which covers all of those vendors as well.
15 May 2012 by Afzal Shaikh
Hy,The Web server is generating internal error log which can give you more details of what went wrongIt is not a client-side issue.This error can only be fix to the Web server software. Web server site operator to locate and analyse the logs which should give further information about...
18 Sep 2011 by Agecanonix
Not entirely sure what you are trying to achieve, but try something like this:[array]$PNGsDirectory = Get-ChildItem C:\FileName\ *.png -recurse | Select-Object Directoryforeach($Directory in $PNGsdirectory) {Write-Host $Directory.Directory.FullName}$PNGsDirectory contains...
21 Mar 2016 by Ajay K.S
When tried to install .Net core using the powershell command and also the set up directly, it's showing some .NET dependency error. I was wondering if I could use this .NET Core without installing .NET 4.0 components.Can .Net core can be installed in systems with .NET framework
12 Mar 2014 by Ajith K Gatty
HTML to PDF Conversion using Sharepoint Management Shell 2010
20 Jun 2011 by Alan N
Yes this is tricky but it seems a work a lot better if you use the -File named argument on the powershell command line.In your case this would bepowershell -File "ScriptwithArguments.ps1" "arg with space"which should resolve toProcess.Start(@"path\to\Powershell.exe", @"-File...
20 Sep 2010 by Ali BaderEddin
Restore an SQL database on a local or remote SQL server using PowerShell
24 Feb 2015 by aljodav
A very easy way to drive PowerShell console application through MFC
26 Feb 2015 by aljodav
Easily reading CodeProject RSS feed for new articles from a MFC Application
27 Feb 2015 by aljodav
An easy way to encrypt files that are automatically decrypted in the same user account
28 Feb 2015 by aljodav
A simple, short and easy way to display a JSON object in a browser (motivated by a forum question)
17 Apr 2012 by Altaf N Patel
try following:Process.Start(@"path\to\Powershell.exe", "&'@"-File ""ScriptwithArguments.ps1"" ""arg with space""'""")
31 Aug 2014 by Ami_Modi
SshNet library for safe connection to Windows Server from asp.net. Now I ant to start\stop any process running on Task Manager. Is it done using PowerShell or any other way? If yes than how can I start PowerShell and than run command from asp.netConnectionInfo connectionInfo = new...
9 Dec 2014 by AminMhmdi
I want to change year of calander and run Specific program and change year after program finishHow can i do this in batch file or powershell script ----------------------i find solution for PowershellSet-Date (Get-Date).AddYears(2) but also i want to do this in Windows Command Prompt
19 Feb 2023 by Andre Oosthuizen
The following might help - $Button1 = Get-ChildItem -Path 'SomePath\SomeFile' | Out-GridView -OutputMode Single -PassThru -Title 'SomeTitle' | ForEach-Object { $_.name } if ($button -eq 'pause') { $button = 'resume' } Write-Host "Button...
18 Dec 2012 by Andreas Gieriet
So far I was using cygwin for my well known Unix scribbles to achieve some quick results on file system and file content manipulations.Since a while, I consider migrating to a pure Windows environment for such tasks. Currently, I'm struggling with the following Bash command line (is there a...
4 Aug 2015 by AndrewXtreme
I am having the same issue and unable to find an answer. Would love feedback on this if anyone has a solution. Thanks in advance
4 Aug 2015 by AndrewXtreme
Ha...Wouldn't you know it? After searching for over an hour, found the answer straight after posting.Needs to be compiled only in x64. Project > Properties > Build > Platform Target x64.
19 Sep 2011 by André Kraak
I found this piece of code[^] that might do the job.
25 Aug 2012 by André Kraak
From Batch File Rename with Windows PowerShell[^]: Dir *.txt | rename-item -newname { $_.name -replace ".txt",".c" }
31 Mar 2015 by Andy Lanng
if this is a winforms application (the "MessageBox.Show" says that it is) then hitting space will trigger an event depending on which control has focus. private void form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == ' ') ps.AddScript("netsh...
21 Jul 2014 by anilv2020
i have below section in web.config should be changed to like below
1 Mar 2021 by aparrygordontafe
Afternoon All, I've been asked to remove applications from office 365, specifically outlook via powershell and the msol service. But i cannot see any information about this? What I have tried: I can remove "services" such as...
4 Sep 2013 by april4413
Hello all,I need some help regarding automatic deployment.In our company there are using tfs2012 for build + for deployment there are using jenkinsI need some powershell scripts for REMOTE DEPLOYMENTS using powershell integrating with Jenkins+TFSThanks in advance.
8 Apr 2016 by arehman_2001
Hello Guys,I need to extract the file 437879_intl_x64_zip.exe silently/quietly without user interaction, I googled a lot but could not find any remedy, I am working in powershell, so solution is powershell would be appreciated you can download the file from...
18 Sep 2013 by Arjan Douwes
Installing multiple SQL scripts using a single PowerShell script.
8 Jul 2018 by arman7404
i have a powershell code and want to update the output of the code automatically to google excel sheet i have result in a powershell varialle $result and want to update the result in powershell please help What I have tried: i have a powershell code and want to update the output of the code...
21 Apr 2015 by Armand Peens
Hi I am struggling to run a 32 bit app from 64 bit Windows Server 2012. When I set it up in task scheduler it never runs. Any suggestions to the following? Thanks.If the Application (which you are trying to schedule) is 32-bit then try launching it from the 32-bit CLI, i.e. if you want to...
24 Jul 2014 by arpoador
From a MFC application (with UI) I want to query PowerShell many times, without instantiating it many times.How can I integrate it (PowerShell) with a MFC application (with UI)?As far as I know, there's no COM objects to use.
25 Jul 2014 by arpoador
How to find out, programatically, the dynamic parameters for Test-Path and Get-Content, for filesystem?
25 Jul 2014 by arpoador
I need to export an array of PSCustomObjects (which contains data about each member of a group), where one of the properties is a HashTable with specific personal data about the group member.I guess I should use a 'Calculated Property' to group these specific personal data in one single...
25 Jul 2014 by arpoador
I need to add a method to my PowerShell script, to perform LINQ in a specific database.Should I either add a type like a class with 1 (just 1) public static method, or, can I add just 1 (just 1) static method through some specialized add type cmdlet's parameter?
1 Aug 2014 by arpoador
PowerShell gives you the correct error message: namespace System.Xml.Linq does not exist.PowerShell v2 uses CLR 2.0, and System.Xml.Linq is not part of it yet.Update to PS v4, it uses CLR v4.0, which has that namespace.
1 Sep 2018 by Arthur V. Ratz
In this brief article, we will demonstrate how to deploy a Node.js application and run it on Docker's Windows Server Core 2016 Containers
25 May 2012 by arunbvg
I am new for PowerCLI Scripting. If I connect with my local host (192.168.1.170). Its connected successfully. But If I connect with Virtual Machine (192.168.1.179). Its throws an error. Details as follows.PowerCLI C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Connect-VIServer...
11 Jul 2011 by Atique Rahman
An article describing some of the tricks of PowerShell scripts and profile that enables you to get a bash like prompt in PowerShell and run applications more flexibly.
19 Oct 2016 by Atish Dipongkor
Writing CAML queries in a optimized, efficient and easiest way.
3 Dec 2014 by Atul_Kapoor
Perform SQL Server Instance health check simultaneously on more than one server using Powershell
13 Jul 2020 by AVT007
I have found a script in this group about compressing a file according to the file modification date. But what I am looking for is to compress log files which are in .jrn format and the file name is like this ABCD20200710.jrn. And the compression...
29 Jul 2020 by AVT007
The script I am working on needs to delete log files in .jrn format after 90 days. The file name is the date itself. Eg.20200720.jrn but the script deletes all the files after execution. Please help required. Also for the initials like...
21 Apr 2014 by awilson9010
Mozilla Firefox MSI using WIX and Powershell
27 Apr 2014 by awilson9010
Building WinPEs from AIK/ADK with Powershell
1 Nov 2020 by awilson9010
Working with Windows BCD store in Powershell
6 Apr 2010 by Ayman M. El-Hattab
Four reasons to directly query SharePoint logging database
7 Dec 2015 by B@dC0d3r
Exchange 2010 user Maintenance
9 Apr 2023 by baburman
I want to launch a simple windows service through Windows PowerShell ISE. My code is as below: $serviceName = "BabServiceInPowerShell" Class BabServiceInPowerShell : System.ServiceProcess.ServiceBase { ...
11 Jun 2013 by Bajirao_
Hi,I am working on C# utility(.exe) which will get SQL Server details. A "VM2" is my SQL Server and utility will be run on it. Now utility will check is there any config db exists on "VM2".if yes then get details like name, ID etc..A point where i stuck is, i can get database details...
19 Aug 2014 by Bark Ups
Hi, You can "ask" remote host to perform action remotely (in background or not), just like you are on host by using PowerShell or if you really need batch file by "older" WMIC.example: c:\wmic /node:hostname process call create "call c:\any_file"where hostname=host you want to...
12 Jul 2012 by barneyman
you've either got to develop an application that understands all the formats you want to search through - Lotus Magellan, anyone? - or use someone else's technologyMS Search seems to know quite a few formats and has an SDK[^]
15 Oct 2018 by BC3Tech
As of this writing, I manage 29 packages on Chocolatey.org. One thing it's imperative package authors do, though, is keep their packages up to date as new versions of the software they're wrapping get released. Without this, packages simply atrophy and the value of Chocolatey goes down.
11 Jan 2021 by Benktesh Sharma
How to create, modify and update Docker image from container
22 Apr 2013 by Bernhard St.
Hi Kuti,gerdid you find a solution for your question?THANKS
22 Feb 2013 by Bharat Nimba Pawar
importing powershell modules and executes CmdLets in windows application using Automation library APIs
7 May 2013 by Bharat Nimba Pawar
I have a x64 dot net console application, to execute powershell cmdlets for Failoverclusters module. I've compiled application with .Net 4.0. Here DotNet4.5 is already installed. I tried to execute this application on windows server 2012. FailoverClusters module loaded successfully on...
20 Nov 2009 by bhavik1st
A simple C# command line utility to demonstrate access to Windows Azure storage.
26 Jun 2020 by BikashBiswal
Hi, I have a requirement to show SharePoint Webpage through Powershell. I have designed a wpf Xaml and able to show the web browser through powershell. The Problem is that when clicking on any hyperlinks on the page it throws error "Do you want...
12 Dec 2014 by BillWoodruff
I'd start here to try and, first, define the issues you will need to address in executing a PowerShell script on a "remote" computer via C#: CodeProject article: Enable Remote PowerShell Execution in C# Jun 3, 2014: [^] "... describes how to execute PowerShell scripts locally or remotely in...
16 May 2016 by Bishnu D
Copy SharePoint 2013 or SharePoint Online Term Stores and their child objects with properties from one environment to another
17 Jun 2015 by Black_Rose
Hi allCan anyone help me how to map a drive using powershell remotely.I tried the below script$computername = (Read-Host "Enter Remote computer to map a drive to")Invoke-Command =scriptslock{ $drivename = (Read-Host "Enter Drive Letter e.g. X:") $psprovider = (Read-Host...
17 Dec 2015 by Black_Rose
Hi AllI am running a unix command which is giving me the below output which i am storing in a...
17 Dec 2015 by Black_Rose
Hi allBelow is the code where i am getting elements in array$a=@($Split_ResultOfMasterListUser)$a | Sort-Object | Get-Uniquebelow is the sample output in powershell...
10 Feb 2016 by Black_Rose
Hi AllBelow is the code what i am doing how and writing the data in a CSV file$Obj = New-Object -TypeName PSObject -Property @{"ComputerName" = $ComputerName "BelongsToOU" = $OUMainName}Add-content $OutPath -Value $ObjBut in...
3 Mar 2016 by Black_Rose
Hi all Below is the code i tried for displaying the values using HTML. but when i am running the application, it is giving me output for only {0} to {4}.. others are not displaying.Please let me know what is the issue.$CurrentSystemHTML =...
29 Mar 2016 by Black_Rose
Hi allI did a script which will list me all the User and there home drives mentioned below.Now i want to check whether those are valid path or not.Manually we can copy-paste and check but how to do it using script.please help me on this.What I have tried:Get-ADUser...
23 May 2016 by Black_Rose
Hi allbelow is the code i am trying to delete content in recycle bin. but after executing also it's not deleting the filesPlease let me know whats the issue.I am running the code at windows server 2012 R2 64-bit.What I have tried:$Shell = New-Object -ComObject...
26 May 2016 by Black_Rose
Hi allI have a hidden folder at my C:\.I want to change the folder attribute to ReadOnly.Please help me on this.What I have tried:Set-ItemProperty -Path "$Directory_Path$Directory" -Name attributes -Value ((Get-ItemProperty "$Directory_Path$Directory").attributes -bxor...
17 Aug 2016 by Black_Rose
Hi allBelow is the xml i am having in a .xml file ...
22 Aug 2016 by Black_Rose
Hi allBelow is my sample input string"Ajeet Tripath amplt;Ajeet.Tripathi@pb.comampgt;;CHetan Singh amplt;Chetan.singh@pb.comampgt;"In this i want the output like belowAjeet Tripath;CHetan SinghPlease let me know how to do this. here is in sample i gave 2 names which can...
20 Mar 2023 by Bogdan Marian
Ensure your Docker Compose services start in the correct order
4 Oct 2011 by bretthamilton
Hello Codeproject,For a bit of background, I am attempting to setup Wake on lan settings in our corporation. We have approximately 50 hardware configurations, mostly Lenova based. Our primary OS is Windows XP. There are a few setting that need to be changed on each PC. Some of these settings...
5 Oct 2011 by bretthamilton
The best way I have found is through a combination of registry Entries.Get the network connections... This information can also be found straight in the registry at the path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}Look for any...
9 Mar 2023 by Bruno van Dooren
How to clean up user profiles on a computer
5 Jul 2022 by Bruno van Dooren
How to read data from OPC DA servers into a PowerShell script
19 Sep 2011 by brunofer2007
Delete all alerts for a specific list or library on SharePoint.
20 Mar 2013 by Bryan O'Connell
A simple script for deleting files in bulk
15 Feb 2014 by Bryan O'Connell
A simple PowerShell script to automate zipping up files and folders.
14 Nov 2014 by Bryan O'Connell
Write a functional test script for a REST API using PowerShell.
11 Feb 2009 by ByteBlocks
How to write custom PowerShell cmdlet.
10 Feb 2009 by ByteBlocks
How to write a snap-in for your custom cmdlet for PowerShell.
15 Feb 2012 by Cai Ming En
I'm kind of new in powershell, so please pardon me..Let's say we want to create a simple .exe file which can be executed in powershell..Let's say the program is basically can do:if "a" is pressed, it will print the string "a is being pressed" on a new line.if "b" is pressed, it will...
25 Jun 2016 by Caio Hamamura
Run unit tests as you modify your code
23 Jan 2012 by Catalin Serafimescu
See if this sample of FileSystemAccessRule helps you look into the right way: http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx[^]