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

Hi Experts,
This is in reference to the following
How do I have users just run that given script by double clicking on an icon or have the below saved as a script?
.\Overlap.ps1 -Path C:\application\book1.csv | Out-GridView

Open in new window

Learn Ruby Fundamentals
LVL 13
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

How can i modify the script below to check if 2 different files exist and also specify the workstation they were found on?

$file="C:\Windows\explorer.exe" -f (Get-Date).ToString("MMdd") #Custom Date time format:  http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
Send-MailMessage -to filecheck@server1.com -from donotreply@test.com -subject "File Checker" -body ("$file Exists: {0}" -f (Test-Path -Path $file)) -smtpServer x.x.x.x

Also, is there a way to do the opposite?  Just email if the files are not found?

How can I remove emails that are in Global Address List that are no longer in office 365 as user or mailbox?

I am trying to get them bu Get-Msoluser or Get-mailbox but I didn't found anything.

And how I can get mail from GAL?
Hi Experts,

I need a powershell command to check each user, how much and which mailboxes connected to this user ?
We use exchange online and O365.

Can you help me out ?
Question, below was a script that I had assistance on a couple weeks back.

This script runs nightly to update extension attributes.

My concern was that if an employee ended up needing less attributes updated, this script won't update the empty attributes they won't need.

Any idea how to add that in here?

$inFile = 'C:\temp\empid.csv'
$outFile = 'C:\temp\empid_log.csv'
Import-Csv -Path $inFile | ForEach-Object {
	Write-Host "Processing $($_.EmployeeID)"
	$out = $_ | Select-Object -Property EmployeeID, SamAccountName, Result
	$hash = @{}
	If ($_.stuff)	{$hash['ExtensionAttribute1'] = $_.stuff}
	If ($_.things)	{$hash['ExtensionAttribute2'] = $_.things}
	If ($_.list)	{$hash['ExtensionAttribute3'] = $_.list}
	If ($_.nice)	{$hash['ExtensionAttribute4'] = $_.nice}
	#Set-ADUser $_.sAMAccountName -Replace $hash
	Try {
		If ($adUser = Get-ADUser -Filter "EmployeeID -eq $($_.EmployeeID)" -ErrorAction Stop) {
			If ($adUser.Count -gt 1) {
				$out.Result = "ERROR: Duplicate EmployeeID: $(($adUser | Select-Object -ExpandProperty SamAccountName) -join ', ')"
			} Else {
				$out.SamAccountName = $adUser.SamAccountName
				If ($hash.Count -gt 0) {
					$adUser | Set-ADUser -Replace $hash -ErrorAction Stop
					$out.Result = "Successfully set $($hash.Keys -join ', ')."
				} Else {
					$out.Result = "No attribute defined."
		} Else {
			$out.Result = "ERROR: EmployeeID not found!"
	} Catch { 
		$out.Result = "ERROR: $($_.Exception.Message)"
} | 

Open in new window

do i need to run the script as is


as my room mailboxes are in office 365.

because when i run the script it comes back with M drive promnpt

do i need to add - exchange online switch in side this script
Question of foreach loop of powershell.

How do you do if you want this loop start from top 2 or top3 or row 10 of the line and down?

I'm trying to enable AD Recycle Bin Feature on our DC, DC is running Server 2016 Datacenter Edition.  I've tried doing this through the GUI, Server Management >> Active Directory Administrative Center >> Select local domain.  The option to Enable Recycle Bin is grayed out.  I then attempted to enable it using PowerShell with the following
Enable-ADOptionalFeature 'Recycle Bin Feature' - Scope ForestorConfigurationSet - Target contoso.com

Return error
Enable-ADOptionalFeature : The specified method is not supported
At line:2 char:1
Enable-ADOptionalFeature 'Recycle Bin Feature' -Scope ForestOrConfigu . . .
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        +CategoryInfo                    : NotSpecified:  (Recycle Bin Feature:ADOptionalFeature) [Enable-ADOptionalFeature],  ADException
        + FullyQualifiedErrorID     : ActiveDirectoryServer:8526,Microsoft.ActiveDirectory.Management.Commands.EnableADOptionalFeature
Hi Experts,

I want to enter this PowerShell command

Get-Mailbox  -Filter{exchangeguid -like "e6ee*"}

Open in new window

But the command is always empty.
Why ?
Hello ,

I am using this command
Get-mailbox | search-mailbox -searchquery 'from:<address>' -targetmailbox <where you want the results> - targetfolder <which folder to put the results in - loglevel full
to export to a mailbox all the emails sent from from a specific user.

I have 2 questions.
1-Is there a way to have also the emails received to a specific user ?

2- The results I am getting are sorted by recipient email address.. Meaning my result pst is a folder that has hundred of sub-folders named after the recipient.
Can I have the result in one folder ?
Exchange 2013

Python 3 Fundamentals
LVL 13
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

There are around 10000 certificates on my CA server, is there any way to export it by using PowerShell?
On a windows 2010 computer using powershell ise (x86),

I run this command:
PS C:\WINDOWS\system32> get-tlsciphersuite

how do i set a filter to only see the entries that include AES
Hi Experts,

I need some help with powershell please.

When I check the command :

get-recipient -identity user | select Displayname, WindowsLiveID, Emailaddresses

But under Emailaddresses I have more emailaddresses, I just want the entry of SMTP
Is it possible to put just the SMTP to the output ?
Need help with getting syntax to work... this works without "Line 6", where I'm clearing out all SIP entries from the proxyaddresses array before setting the next line.  Is this a syntax issue, or would I need to use in a separate function?

        Set-ADUser -Identity $User `
        -UserPrincipalName $SmtpAddres `
        -EmailAddress $SmtpAddress `
        -clear msRTCSIP-PrimaryHomeServer `
        -replace @{'msRTCSIP-PrimaryUserAddress'="SIP:$SmtpAddress";'msRTCSIP-UserEnabled'=$true"} `
        &{Get-ADUser $User -pr proxyaddresses | select -ExpandProperty proxyaddresses |? {$_ -cmatch '^SIP'}} | % {Set-ADUser -Identity $User -Remove @{proxyaddresses="$($_)"}}  `
        -Add @{proxyAddresses="SIP:$SmtpAddress"}

Open in new window

Need some help with deciphering this vbscript... this script first runs a dsquery to grab all users and DN's into a file.

Basically line 12, I'm looking to grab the DN where it builds a strNullset variable to determine if @Domain or @Domain2.org - is there a way to do this in powershell without dumping out all of the users in a file, then append later in the script?

Also looking for what line 24 actually does with the "2", and also what line 29 does... ?

Set objArgs = WScript.Arguments

If objArgs.Count < 1 Then
	Wscript.Quit -1
End If
strUserDN = objArgs(0)

Set objUser = GetObject("LDAP://" & strUserDN)
If UCase(objUser.AccountDisabled) = "FALSE" Then 
	strNullSet = objUser.sAMAccountName & "@Domain.org" 
	If InStr(UCase(strUserDN),"Domain2") Then   
		strNullSet = objUser.sAMAccountName & "@Domain2.org"
		End If
	If objUser.mail = "" Then                             
		If objUser.userPrincipalName = strNullSet Then 
			objUser.put "userPrincipalName", strNullSet    
			WScript.Echo objUser.sAMAccountName & "," & strNullSet & "," & objUser.userPrincipalName & "," & "Null"
		End If
		If objUser.userPrincipalName = objUser.mail Then  
			strO365Alias = "smtp:" & objUser.sAMAccountName & "@cchs.mail.onmicrosoft.com"
			If objUser.mailNickname = objUser.sAMAccountName & "2" Then
				strO365Alias = "smtp:" & objUser.sAMAccountName & "2@mail"
			End If
			objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", 

Open in new window


I have Exchange 2013:

MBX01: Mailbox server and Hub Transport roles
CAS01: CAS and Front End Transport rules

I created a Receive Connector for mail relay. So in DNS SMTP.MyDomain point to CAS01

When I send an email from an application and use SMTP.MyDomain as my smtp the flow is like this:

Client ---> CAS01---> MBX01---> MX recipient server

When I do a message tracking logs from PowerShell the source is always from CAS01 but I need to know the real source like client IP. How can I obtain that?
Hello Experts,

I need some help with a query preferably a wmi query that would detect only the 32 bit office. I need to deploy a reg key in a GPO.

I have two csv files that i want to compare with each other,

one is the baseline with all my information in it.. will call it baseline.csv
The other is an export from our Student information systems which ill call export.csv

Now the baseline.txt is all the data i want to keep, including students who have transferred out.
the export.txt which is run daily may have new students, and may be missing some that have transferred out.

I just want to compare the export.csv to the baseline.csv and get an output of new students.... so i can add them to the baseline.csv

I am hoping this makes sense.

i have a problem with user redirected/home folder, he lost access on many file and sub folder , when i see those file and folder not have owner.

how i can use a command line to take the user owneship on all those filer and folder and may be need to add him full controll access on it.

the home folder file is located on \\server\users\jhon.smith\subfolder....

thanks for help
Exploring SharePoint 2016
LVL 13
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Dear expert

I been thinking of looping foreach with two diffirent variable arrays. For exemple:
$var1 = "server1", "server2", "server3"
$var2 = "sqldb1", "sqldb2", "sqldb3"
Foreach ($varserver in $var1, $vardb in $var2){

Open in new window

This is for doing this then:
$SqlConnection.ConnectionString = "Server = $varserver; Database = $vardb;

Now this is not working... Foreach ($varserver in $var1, $vardb in $var2){ doesn´t work like this. Is there any other way?

Really need some help with powershell script to pass attribute for identity in a variable set.  I'd like to use this in another script and call as a function to create mailboxes which has the Samaccountname defined.

The variables in this script are defined as:
        $Prefix = $User.samaccountname
        $UPN = $User.UserPrincipalName

But the $prefix is NOT passing for the user I input.

I pulled the Add mailbox code out of this script:  External Licensing Script

The script I have is here, I'm doing an external connection to exchange in one function, and have another function to create the remote mailbox.

Function Connectexchange {
    $Username = "adminmsol@cchs.onmicrosoft.com" 
    $Username2 = "domain\admin" 
    $Password = ConvertTo-SecureString 'Password@' -AsPlainText -Force  
    $Livecred = New-Object System.Management.Automation.PSCredential $Username, $Password  
    $Livecred2 = New-Object System.Management.Automation.PSCredential $Username2, $Password   
    $ExchangeServer = "Exchangeonprem.domain.com" 
    $DomainUpn = "domain.com" 
    $TargetAddress = "company.mail.onmicrosoft.com" 
    ##Connect to Exchange Server to Create the Remote Mailbox## 

Open in new window

Hello experts,
I am looking for a script to :
-Upload file to an url
-Download specific and last modified file from a url
To access to this url I need to report credentials. User and password.
I heard about cUrl application however if this is possible through a build-in language such as powershell or vbscript I a prefer this approach.
As regards the upload and the download the script should manage success and error actions in a log file.
Thank you in advance for your feedback.
I am using powershell to search a string looking for a particular value, the string is part of a URL
Lets say the string consists of characters like this

"GFiYXNlaWQ9NTAwJmFtcDtzZXJpYWw9MTY4NTEwODQmYW1wO2Vt      Experts-Exchange               14.92"

I'm using Indexof to find Experts-Exchange, then based off of that location I want to find the start of the decimal number after the white spaces.  I cannot figure out how to do that, any suggestions?
Hello Experts,

Using a script, How do I get all audit events with eventid 4663 from security logs only when a particular file dataconfig.xml was changed.

Eventid = 4663 and objectname contains dataconfig.xml

Thanks very much.
I'm using the latest version of MDT to create our image.  The provisioning process uses a local user account to set up the computer.  I can create the account using the unnatend.xml modified by MDT to create the account, but my issue is creating the profile folder structure for that account (I need to copy a couple of files for that account).  I have found that I can manually have the profile created by taking an application that is on the computer and using the "Run as different user" option to run it using the local user's credentials.  However, I would prefer not to have to stop the process to manually do that and would prefer doing that programmatically.

Any suggestions will be appreciated.

Please let me know if you have any questions.







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.