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

Need help writing a PowerShell loop.
I have the following code already, and it works except for the first item.  I end up with a "," (comma) to start, which I don't want.
Also there cannot be a "," (comma) at the end, the last path cannot have anything after it.

    ForEach ($tmp in $DependenciesList) {
		$Dependencies += "," + $tmp.FullName

Open in new window

$DependenciesList is an array of file path objects obtained by code previously in my script that populates the array from what it finds.
$Dependencies becomes a string made up of these paths separated by a comma.

I need each path to be separated by a comma (no spacing) and no comma at the very end.
For example, I need the output to look something like this:
C:\Path1\SubPath1,C:\Path2\SubPath2,C:\Path3\SubPath3, ... ,C:\PathX\SubPathX

Open in new window

How can I modify this ForEach loop?
Build an E-Commerce Site with Angular 5
LVL 13
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

I am analyzing  what is the best portable solution for a database....and it seems the question is between SQL LITE and MS SQL CE 4.0 sp1.

With that said I have a very large table in SQL Server.  So far it has created some 500 files of SQL for CE and it looks like LITE will be even more as the file sizes are smaller.

With that said It looks like Microsoft has pretty much abandoned CE compared to LITE.  

I will need to use this in a Winform c# app that will connect to one table...perform a very basic LINQ query.

so my question is 2 parts.  Which is the best.

And finally since this is creating so many files in my migration ...what is the best way to execute these files versus clicking on them and running them one at a time.

I would imagine they could be ran in batch with powershell or someothe tool.

Any guidance would be great!

I have a shared mailbox which I need to setup multiple Out of Office schedules.

Out off Office Monday - Friday 18:00 to 08:00 and Out of office all weekend (so basically from 18:00 Friday evening to 08:00 Monday morning).  

It does't look like this can be done via out of office option in Outlook?  I've seen some Powershell scripts online which can be run as scheduled tasks, but they don't give examples of how to define multiple schedules and presumably I'd have to then run the schedule task on the Exchange server (which is not ideal) as we configure users PC's to go to standby when they are not being used.  

Interested to know what the best options are here and if anyone's already written a script which does what I want?

I'm using Exchange 2013 on-prem and Outlook 2016

Thanks in advance.
Can not install or remove exchange 2016. I was installing CU12 and the update crashed. I tried to rerun the update but got errors. I followed the suggestions (https://exchangemaster.wordpress.com/2010/08/11/cannot-install-or-uninstall-an-exchange-role-after-a-failed-disaster-recovery-install/)
The server was in a DAG. I removed it from the DAG. Exchange powershell doesn't work on the server.  the error message I get when I run the recover/setup is:

The following error was generated when "$error.Clear();
          & $RoleBinPath\ServiceControl.ps1 -Operation:DisableServices -Roles:($RoleRoles.Replace('Role','').Split(',')) -SetupScriptsDirectory:$RoleBinPath;
          & $RoleBinPath\ServiceControl.ps1 -Operation:Stop -Roles:($RoleRoles.Replace('Role','').Split(',')) -IsDatacenter:([bool]$RoleIsDatacenter)
        " was run: "System.Management.Automation.PSInvalidOperationException: Cannot find the Windows PowerShell data file 'ManageScheduledTask.Strings.psd1' in directory 'C:\Program Files\Microsoft\Exchange Server\V15\Bin\en-US\', or in any parent culture directories.".

The en-US directory doen't exist. I scanned the V15 and sub directories for the missing file. I doesn't exist.

Thanks for the help
I run dnscmd /zoneexport mydomain.local backup\mydomain.local.bak to back up my DNS each week. I then rename the file mydomain.local.bak and copy it out of System32\dns to an alternative location. I need the syntax that will import the entire file into DNS. dnscmd /zoneadd just created a new zone. Again, I need the syntax that will import the entire file into DNS. No powershell please if possible
I have a CSV file with an "email" column. This won't necessarily match a UPN of an AD user, but it should be contained in the proxyAddresses attribute of a user in AD. If not, then I'm looking to get that reported into a variable/separate list if possible.  
It appears I can get all the users in AD where "$proxyAddress -contains $csv.email" but I can't reverse and do a -notcontains.  
Is there any idea how I can achieve this
Issue in Brief: Unable to add node back to the cluster.

Details of the issue: We noticed that one of the nodes in the two node cluster(node & disk majority) is 'down' in FCM.  However, we're able to ping it from another node and also RDP into it.

Troubleshooting Performed:
-Tried to evict and re-add the problematic node to the cluster, but unsuccessful in doing so - both via. PowerShell and via. GUI.
-Also rebooted the node, and performed the above operation.  Still no luck.
  Error: Unable to successfully cleanup.
-Applied "Clear-ClusterNode" and it was successful.
-Then, tried to re-add the node but received the same error, but through GUI & PowerShell.
-Rebooted the problematic node; still getting the same error.
-Upon further investigation, we noticed that  the "CLUSDB" was missing in the registry of the problematic node.
-Copied the database to the problematic node (from the other node), and tried to load it in the registry, without success.
-Then copied the "CLUSDB.blf" file to the location, renamed it to "CLUSDB" and tried to add the node again.  Still getting the same error.

-Looked into AD, and found the appropriate CNO for the cluster, and VCOs of its corresponding nodes.

-Noticed below error in the cluster logs as part of our investigation.

"New join with n2: stage: 'Authenticate Initial Connection' status HrError(0x80090301) reason: '[SV] Authentication failed'"

-Did a "portquery" on the other node, from the problematic node and it …
Is there anyway via a powershell command to get a hash of a file in order to identify duplicates, or are there any alternative ways via powershell to audit a file server to identify duplicate files.
Do any of the powershell cmdlets have the ability to identify all office files which are encrypted / password protected, e.g. is there any sort of attribute on those files whereby you could use a powerful command to list all files on a share, and which are encrypted/password protected or not. I am not sure if files in general have a generic attribute to show this, or if each software supplier would store this attribute in different ways (making this an almost impossible task). i.e. Microsoft office documents, adobe PDF's.
Exchange 2013 CU20, Powershell to save attachments from specific mailbox to a share. I found a powershell (attached) but I keep getting errors when running it. I get the following errors -

Exception calling "Bind" with "2" argument(s): "The specified object was not found in the store."
At C:\scripts\saveattachments\SaveAttachment.ps1:24 char:1
+ $InboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$fold ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ServiceResponseException

You cannot call a method on a null-valued expression.
At C:\scripts\saveattachments\SaveAttachment.ps1:33 char:1
+ $frFolderResult = $InboxFolder.FindItems($sfCollection,$view)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
Expert Spotlight: Joe Anderson (DatabaseMX)
LVL 13
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

I have txt file that contation list of ip for example
I want to make a script with power shell
that generate anew file for my MikroTik to add the ips to address list the final file will be for example: list.rsc
/ip firewall address-list
add address=1,1,1,1 comment="lsit" list=anti
add address=  comment="lsit" list=anti
add address=  comment="lsit" list=anti
add address= comment="lsit" list=anti

We have 2 forests contoso.com adataum.com ; a forest trust was confugured between the 2 forests . The email services are on contoso.com , we need to allow U_exchAdmin_adatum group at adatum.com to manage exchange services on contoso.com.

We we able to allow U_exchAdmin_adatum users to log to ecp on contoso.com  , but could not run exchange management shell .

when attempting to log to exchange management shell getting the following error :

New-PSSession : [Exch07.contoso.com] Connecting to remote server Exch07.contoso.com failed with the following error
message : WinRM cannot process the request. The following error occurred while using Kerberos authentication: Cannot find the computer
Exch07.contoso.com. Verify that the computer exists on the network and that the name provided is spelled correctly.

Open in new window

ran the following command on Exch07:
(Get-PSSessionConfiguration -Name Microsoft.PowerShell).Permission

Open in new window

was showing "Adminsitrators" and "Remote Management users" are allowed access ; made the group "adatum\U_exchAdmin_adatum" members of the local admin on Exch07 , but that did not resolve the issue.

Did you face such issue or have some hints how this may be resolved?

I need assistance in trying to remove all gmail accounts signed into chrome on a public computer using powershell. I tried the following and substituted the parameter "USERNAME" with the real username.

Remove-Item -path "C:\Users\$env:USERNAME\AppData\Local\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -EA SilentlyContinue -Verbose
Write-Host -ForegroundColor yellow "Google Chrome Cache Removal - COMPLETE"

Open in new window

Can someone be able to provide some guidance on this?

Many thanks in advance.
Hello can someone please help me to get a report of the active users and their mailboxes. I am looking for something like this

Name lastname username mailbox

I am using powershell and exchange cmdlets

Hey Experts!  The script below deletes out the user's profile on the computers in a text file.  However the script isn't deleting out the user's AppData folder.  It's staying on the computer and I'm hopeful we can tweak this script so the AppData dir is deleted when the profile is wiped out.

Get-ADComputer -Filter 'Name -like "TRN3*"' -SearchBase "OU=COMPUTERS,OU=TRAINING,OU=DEPTS,DC=LOCAL" -Property * | Select-Object -ExpandProperty name | out-file c:\tools\logs\testlog.csv

$computerList = Get-Content c:\tools\logs\testlog.csv
$logFile = "c:\tools\logs\testlog.csv_$([DateTime]::Now.ToString('yyyyMMdd')).csv"

$dateTime = {[DateTime]::Now.ToString('yyyy-MM-dd HH:mm:ss')}
$computerList | ForEach-Object {
	$computerName = $_
	Write-Host "Processing $($computerName) ..."
		ComputerName = $computerName
		Date = & $dateTime
		Type = 'Cleanup Start'
	If (Test-Connection -ComputerName $computerName -Count 2 -Quiet) {
		Try {
			$diskC = Get-WmiObject  Win32_LogicalDisk -Filter "DeviceID='C:'" -ComputerName $computerName -ErrorAction SilentlyContinue
			$diskSize = [math]::Round($diskC.Size / 1GB, 2)
			$freeSpaceBefore = [math]::Round($diskC.FreeSpace / 1GB, 2)
			$profiles = Get-WmiObject -Class Win32_UserProfile -Filter "(Special='False') And (Loaded='False') And (Not (SID Like '%500'))" -ComputerName $computerName -ErrorAction Stop
			If ($profiles) {
				$profiles | 

Open in new window


We are looking for a powershell script that can check if a admin user have access to RDP from a list of server.
I have tested " New-Object System.Net.Sockets.TCPClient " with port 3389 to a server, but the result did not say if logged on user had access.

Is it possible to do this and get a output in a txt file?

Environment: Exchange Server 2013

I am trying to remove a Public Folder in my Exchange Organization, but it is not allowing me to.  It is saying that that is mail enabled.  So I tried to Disable the mail-enabled feature, and it says it's not mail enabled.  
Here are the exact errors in Powershell that contradicts itself:

[PS] C:\Windows\system32>Remove-PublicFolder -identity "\Cnf-room-Computer-Training"
The public folder is mail enabled. Please disable it for mail before removing the public folder.
    + CategoryInfo          : InvalidOperation: (\Cnf-room-Computer-Training:PublicFolderIdParameter) [Remove-Publ
   lder], InvalidOperationException
    + FullyQualifiedErrorId : [Server=<SERVERNAME>,RequestId=0e6d9d2b-1609-4526-970e-5ba2d989b00b,TimeStamp=4/11/2019
   4:49 PM] [FailureCategory=Cmdlet-InvalidOperationException] EE0D840E,Microsoft.Exchange.Management.MapiTasks.Re
    + PSComputerName        : <SERVERNAME>.DOMAIN

[PS] C:\Windows\system32>Disable-MailPublicFolder -identity "\Cnf-room-Computer-Training"
Public folder '\Cnf-room-Computer-Training' isn't mail-enabled.
    + CategoryInfo          : NotSpecified: (:) [Disable-MailPublicFolder], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : [Server=<SERVERNAME>,RequestId=f42596cf-bf3c-48ee-a8a4-665a4c0a81cc,TimeStamp=4/11/2019
   6:26 PM] [FailureCategory=Cmdlet-ManagementObjectNotFoundException] 7DC1D639,Microsoft.Exchange.Management.Mapi…
I have a request to replace existing Primary SMTP in exchange environment with name.surname@domain.com

I am trying to build a powershell script that will pass by every user, check their existing Primary smtp if it's SMTP:name.surname@domain.com

If it's like this it'll write-host User has name.surname format and will show the user's primary SMTP address

If not then the script will change Primary SMTP to secondary and add Primary SMTP name.surname@domain.com

I would appreciate if anyone could help me with this .

Thank you

I need to expert the Global addresses list from a exchange server and import it into 0365 as contacts, does anyone know if there is any software i can use ? or how i can export the GAL and use powershell to import it into 0365 ?


Become a CompTIA Certified Healthcare IT Tech
LVL 13
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Hi techs,

I have a Windows Server 2012R2 system which is stuck in OOBE, and as such, is not receiving updates automatically.
I've been able to manually install windows updates using the steps in this article which allowed me to get 15 updates installed via Powershell, but the GUI method still fails.

The server was built in 2017, had WSUS offline patches applied to it, but hasn't been patching since

I've tried:
- sfc /scannow
- dism /online /cleanup-image /restorehealth
- dism /online /cleanup-image /restorehealth /source:z:\winsxs /limitaccess (to use another functioning windows system as the source)
- sysprep /oobe /reboot to get it out of sysprep
- manually update Windows Updates components (based on https://support.solarwindsmsp.com/kb/solarwinds_n-central/Microsoft-Windows-Update-Agent-Updates )
- registry changes to get it out of OOBE
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ 
 IsOOBEInProgress  change to 0 from 1

Open in new window

- reset the Windows Update components by stopping BITS, Crypographic, Winodws update services and renaming c:\windows\softwaredistribution to .old
- cleared the contents of the c:\windows\system32\catroot2 folder
- waited 5 days for the progress bar to progress
- confirmed server is not misconfigured to use WSUS
- reset the proxy settings using netsh winhttp import proxy source=ie
- reset the WindowsUpdate.log file to be able to get some fresh data, source below:

Open in new window

if the filename's date creation is 20190409_1400, how do I get that date/time to rename the file with this extension.

EXAMPLE: myfile.pdf has a DATE CREATION property of 20190409_1400

RESULT: myfile_20190409_1400.pdf
I had this question after viewing Sharepoint Upgrade Failed.

We have Sharepoint 2013.  We had some outage due to fab 40 template (Ctype feature). We have some sharepoint lists which are using fab 40 templates. We need to identify those sharepoint list and remove from farm.

How do i identify those sharepoint lists?
Hi,  in powershell:

1) From the right, after the first PIPE SYMBOL | , how do I get the path and filename that follows?

EXAMPLE: I want the string to the right of the word "MAIL|"



2) filename and extension:


3) filename only:


4) from the left after the first PIPE | symbol, pare the data


when a batch-file is executed in cmd. I want to make sure that exactly one parameter has been passed.
How can I do this?
Hi Experts,
 We have sharepoint 2013 environment. Recently we have outage and our site was not loading. After contact MS, we found that there was a CType feature activated site level (FAB 40 template) and it's causing the  performance issue. Now we have to find the out which lists is using this feature.

I need your help to find out the lists which uses the Ctype feature. Can you please help me get some scripts?

Thank You






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.