Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

Share tech news, updates, or what's on your mind.

Sign up to Post

I would like to create a Powershell script to copy folders and files from a domain computer to a non-domain computer.


Domain computer name is: "DName"
Domain user is: "Domain\DTest"
Password is: "domainpass"
Source Folder Path: "C;\TestFolder\"

Non-Domain computer name is: "LName"
Non-Domain user name is: "LName\myname"
Non-Domain password is: "localpass"
Destination Folder Path: "C:\TestCopy\"

I have tried a few attempts with no luck.

Any help is greatly appreciated.

Hire Technology Freelancers with Gigs
LVL 12
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

We have a Throttling Policy in Exchange 2010 that sets the RecipientRateLimit to 1000.  We have a user that got a virus and was sending tons of emails.  Well he hit the rate limit and now is unable to send email for 24 hours.  

Now that we've cleaned up his device and changed his password, is there a way to reset the RecipientRateLimit count for this individual?


I'd like to see if a remote pc can connect to a server on a certain port via Powershell.
PSNMap does a great job of scanning to remote computer https://www.powershelladmin.com/wiki/Port_scan_subnets_with_PSnmap_for_PowerShell 
but howto do this from computer x, to computer y <=> computer z on port 123?


Might have something here via invoke-command but not sure if it DOES run correctly remote and also have a function which does a  check-remotecomputerport -destinationcomputer -ports
and should also clearly show "ComputerToWhichPortsAreTested" and "$ComputerFromWhichPortsAreTested".

$sb= { 
     function Invoke-PSnmap
	param (
		# CIDR, IP/subnet, IP, or DNS/NetBIOS name.
		[Parameter(Mandatory = $true)]
		[Alias('PSComputerName', 'Cn')]
		# Port or ports to check.

		# Perform a DNS lookup.

		# Scan all hosts even if ping fails.

		# Number of concurrent threads.

		[int]$ThrottleLimit = 32,
		# Do not display progress with Write-Progress.

		# Timeout in seconds. Causes problems if too short. 30 as a default seems OK.

		[int]$Timeout = 30,
		# Port connect timeout in milliseconds. 5000 as a default seems sane.

		[int]$PortConnectTimeoutMs = 5000,
		# Do not display the end summary with start and end time, using Write-Host.

	# PowerShell nmap-ish 

Open in new window

Hi All,

I have these three commands that i am trying to script:

.\emcopy64.exe \\sreadvfile03\f$ \\sreadvfile02\g$ /o /s /de /secforce /purge /cm md5 /r:1 /w:1 /c /log:sreadvfile03_fdrive_$(Get-Date -format "dd-MMM-yyyy_HH:mm").txt

.\emcopy64.exe \\sreadvfile03\e$ \\sreadvfile02\f$ /o /s /de /secforce /purge /cm md5 /r:1 /w:1 /c /log:sreadvfile03_edrive_$(Get-Date -format "dd-MMM-yyyy_HH:mm").txt

.\emcopy64.exe \\sreadvfile03\z$ \\sreadvfile02\h$ /o /s /de /secforce /purge /cm md5 /r:1 /w:1 /c /log:sreadvfile03_zdrive_$(Get-Date -format "dd-MMM-yyyy_HH:mm").txt

Open in new window

so far my solution is:

$copy=@(@{source="\sreadvfile03\f$";destination="\\sreadvfile02\g$"}, @{source="\\sreadvfile03\e$";destination="\\sreadvfile02\f$"},@{source="\sreadvfile03\f$";destination="\\sreadvfile02\g$"}) 

foreach ($m in $copy){

.\emcopy64.exe $($m.source) $($m.destination) /o /s /de /secforce /purge /cm md5 /r:1 /w:1 /c /log:$($m.source)_fdrive_$(Get-Date -format "dd-MMM-yyyy_HH:mm").txt


Open in new window

will the above work?

Also how do i select the correct drive in $($m.source)_fdrive_$

also any other ways of doing as this as i am trying to master powershell?
Dear expert

I been looking for a way to monitor the bluetooth signal strength in Powershell, I would like to monitor between a device with computer signal strength. There is alot of way to check for WIFI not really for bluetooth.

Anyone know anything about it?

Dear Community,

In our company we implemented an MDT infrastructure to deploy Windows 10 to notebooks. Most of our phyiscal device have more than one hard disk installed. Usually there are two disks. One SSD disk and a normal HDD. The target is to install the Operating System to the SSD (if there is one installed).

Our challenge:
Usually the first disk loaded disk in Windows PW gets ID 0, the second loaded Disk gets ID 1 and so on. There are notebook models, where the SSD is does not get Disk ID 0. In our task sequence the we specified to install the operating system to the Disk with the ID 0. Of course I could change that for these specific notebook models, but that is not the target.

Already tried:
- Added the following featuers to Windows PE: DISM Cmdlets, Enhanced Storage, .NET Framework, winpe-platformid, Windows Powershell, Storage Management Cmdlets
- WMI Filtering and Powershell Filteroptions (two examples)

Example 1 - Get-WmiObject -Class Win32_DiskDrive
For this command there is no possibility to see if the disk is an SSD or not

Example 2  - Get-WmiObject -Class MSFT_PhysicalDisk -Namespace “root\microsoft\windows\storage”
With this command I can filter by media type and see if it is an SSD or an HDD, but this command is not available during Windows PE. After the a successful OS installation it is possible to execute that command in Powershell.

References that I tried:
- …
I want to find how DNS is setup for scavenging, is there any small Powershell scripts to get an overview of how DNS is run, windows 2008\2012r2 environment
Power shell script for creating subfolders inside of parent folder remotely

Here is what I'm trying to use and it works for one location would like to set multiple locations on a remote computer or computers

set-location \\fileshare\e$\folder\folderA

$folders = import-csv e:\scripts\folders.csv
foreach ($folder in $folders){

New-Item $folder.name -type directory -force


CSV Text file


Now instead of setting one location @ the remote computer location I would like to setup multiple locations to create these sub-folders

so this is what I was going to try   The locations are all going to be located on one server each time so Server A then I'll modify it for Server 2 etc ......

$locations = set-location "path1", "path2", "path3"

foreach  ($location in $locations) {

$folders = import-csv e:\scripts\folders.csv

foreach  ($folder in $folders){

New-Item $folder.name -type directory -force

Powershell Script to get Home Drive (Homedir) size for list of users in CSV file with only Samaccountname
Hi All

Does anyone have a Powershell script to share that would do the following ?

1) gets the path form a text file .. example below .. with 100s  of paths
2) checks if a set of domain credentials can access each share.
3) output CSV with each path and if the account was able to access the share or not .
Simplify Active Directory Administration
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Powershell Script to get mailbox size in MB for list of users in a CSV file with only Samaccountname
Hello experts,

I need to list accounts which matches the following filter:

Enabled = True and
If the employeetype attribute  contains any values with A* (A1, A2, A3...), B* (B1, B2, B3...), C* (C1, C2, C3....), D* (D1,D2,D3,....)

EmployeeType - A*, B*, C*, D*

$UserList = Get-AdUser -Filter ( ) and -Enabled

Please assist.

Thank you.
Anyone have a script to List all mailbox folders and all permissions granted to the folders? We have a customer with hundreds of mailbox folders and they want to know who has access to each one with out going through one by one.

I am trying to write a powershell script to add a O365 License to a subset of users.  I figure if I can get it to work for one I can make it work for multiple

This is as far as I get...
Set-MsolUserLicense -UserPrincipalName Mark.jones1@xxx.com -AddLicenses XXX:ENTERPRISEPACK  

I need to be able to add "Microsoft Team" and "Microsoft Planner"  

When I run Get-MsolAccountSku  I dont get the subset of XXX:Enterprisepack

Any thoughts out there?
I would like to have a way to programatically query VSTS builds/releases etc from powershell. Is there a library that I can use for this - and maybe a very basic example to get me started?
Dear expert

I need help with code below. Script does stop all the service that have name: Apsvx*
Now I have permission problem running this, now I do have a administration rights account, but this code is running in a program that runs using a user rights permission.
However I come up a workaround! If you first create a variable name: $credential with administration rights account login info and below code run as that, then it would work.

Anyone know how to do that?

Get-Service -DisplayName Apsvx* -ComputerName ServerIP | ForEach-Object {
	$result = $_ | Select Name, DisplayName, Status, Result, Error
	Try {
		Stop-Service -InputObject $_ -ErrorAction Stop
		$result.Result = 'STOPPED'
	}Catch {
		$result.Result = 'FAILED' }

Open in new window

Microsoft Exchange 2016

I have a script run under a normal domain user through scheduled tasks to find distribution groups that match a certain criteria and set them to allow external senders. The user has a role with the Distribution Group entry permissions (which includes Get & Set-DistributionGroup). I've tested this user via the EAC and it can see the groups I want and change the RequireSenderAuthenticationEnabled attribute.

From PowerShell as the user typing the commands individually or as the user using the script, the Set-DistributionGroup cmdlet throws an error. I can load the snap-in, run the Get for the results I want but cannot run the set. I understand that giving the user Org Management and/or Admin rights will work around this, but to do so defeats the purpose of the roles and gives the user *far* more access than is needed.

Set-DistributionGroup : No provisioning handler is installed.
I need to export all configuration parameters from my old Exchange 2007 EdgeTransport server and import it into to my new Exchange 2013 Sp1 Edgetransport server. Is there a tool or a PowerShell commands that I can use to expedite the cut-over? I also have  Forefront server running on my old exchange 2007 Sp3  and I need to export all the config to my new Exchange 2013 SP1 EdgeTransport server as well but the categories are not the same so it's a slow tedious process at the moment. any assistance would be greatly appreciated. thanks you.
Hey.... I am trying to update fields in AD from a csv file.  For some reason whenever I run my code it is DELETING the title and not displaying the finished results in a new csv file. Please help. [ ]Write-host  "Processing"

Import-module ActiveDirectory

import-csv -path C:\Users\AliciaM\Documents\CurrentEmployees1.csv |
ForEach-Object{Get-ADUser -Filter “EmailAddress -eq `"$($_.EmailAddress)`""| Set-ADUser -Title $_.Title -Description $_.Description| Select CN, EmailAddress, Title, Description }  |

Export-csv C:\Users\AliciaM\Documents\FinalCurrentEmployeesResults.csv

Write-Host "Done"[/code]
SMB Security Just Got a Layer Stronger
SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

I have one computer that I cannot connect to remotely on the network. When I try to access the PC remotely using PSEXEC I get "The network name cannot be found. Make sure that the default admin$ share is enabled on computerA". I can connect to it using Windows "Services", and when I start the WinRM service (which is set to manual), I can connect to the remote computer using Powershell. Once in Powershell on the remote computer, I am connected as my user account, which I think is normal. In powershell when I use the command "Net use \\localhost\admin$" or "Net use \\localhost\c$" it shows that it is enables and connected.
When I try to connect to the PC using Windows Explorer, I get  "The remote device or resource won't accept the connection". The weird part is that I can ping the PC by name, I can connect to the "Services", but I cannot connect to registry, I cannot connect to it using PSEXEC, and other methods. I have verified that the firewall is off, I have verified that file and print sharing is enabled, I have also (in Powershell) verified that registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer is set to 1.
Can someone help me get the computer to the point where I can use PSEXEC, and other tools? I am happy to send screenshots or report back on anything that will help identify the issue.
I would like to run a script, which will look at a specific folder in a path (ie C:\users\user1\desktop\desktop.zip), and encrypt that zip file with a password.
is this possible, please let me know.
Need to monitor ZIP files that are older than 3 hours. I have the following code can someone let me know if will work ?

param([string]$path, [int]$minutes)
    $LastWrite = $(Get-Date).AddMinutes(-$minutes)
    $FileArray = $(Get-ChildItem $path | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $LastWrite })
    if ($FileArray.Count -eq 0)
        $msg = "No files found over $($minutes) 3 hours old"
        $msg = "$($stat) files found older than $($minutes) hours: "
        foreach ($file in $FileArray)
            $msg+=" " + $file + ","

Write-Host "Statistic: $stat"
Write-Host "Message: $msg"

exit 0

Open in new window

And, this is how i run it
PS C:\Scripts> .\FileAgeMonitoringWildCard.ps1 "\\SERVER\d$\InetPub_Test\KSFTPWebService\*.zip", 180
Statistic: 0
Message: No files found over 0 3 hours old

Open in new window

Eventually, i need embed this script into solarwinds.

Thanks for your help,
Is there a PowerShell command similar to either one list below that will show me if a specific "Trusted Root Certification Authorities" certificate is installed in IE on a remote computer, listed by it "Issued To" or "Friendly name" ?

Get-ChildItem -computername RemoteComputer -Path Cert:\LocalMachine\TrustedPublisher | Where-Object {$_.Issuedto -eq "?Friendly Name of Cert"

invoke-command -computername RemoteComputer  {Get-ChildItem -path cert: -Recurse | where { $_.Subject -like "*Name of Cert*" }}
Hello ,
I have a folder with .jpg files inside. The files are pictures of users  and are named using their correspondent "ext attribute 1" .  I have also exported to a csv file all users inside an OU with Name, SamAccountName, extAttribute1.  extAttribute1 has 7 digits.  
Now, I need to for all files in the folder that have a file name with 7 digits to rename it to it's correspondent SamAccountName . If file name exists with SamAccountName, overwrite it.
I have several powershell commands to obtain .csv with the files name and the other mentioned before with AD account information for users in OU.
Can someone help me to achieve this.
I've been trying to figure out how to do this but I'm always met with a bump on the road. What I'm trying to do is to get the reporting people under my manager's direct reports list; so for example, "Alex" is a direct report under my manager, however, when you go into his organization you see that he also has direct reports that report directly to him - I am trying to get "those" reports not only from his side but from anyone else in the list that has direct reports as well. What is needed for me to effectively execute that idea? Many thanks!

This is my code to only get Direct Reports under my manager tree:
    public void GetManagerDirectReports()
            Application App = new Application();
            AddressEntry currentUser = App.Session.CurrentUser.AddressEntry;
            if (currentUser.Type == "EX")
                ExchangeUser manager = currentUser.GetExchangeUser().GetExchangeUserManager();
                if (manager != null)
                    AddressEntries addrEntries = manager.GetDirectReports();
                    if (addrEntries != null)
                        foreach (AddressEntry addrEntry in addrEntries)
                            ExchangeUser exchUser = addrEntry.GetExchangeUser();
                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine("Name: "
                                + exchUser.Name);

Open in new window







Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.