Powershell

18K

Solutions

8K

Contributors

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

Recently a users mailbox may have been compromised to send a phishing email.  I checked the message tracking log and it showed that an email with the same subject was sent from the employee to 3 other employee emails.  I originally thought that this was a spoofing attempt and the email originated off-site.  But, at this point from what I can tell the logs indicate otherwise.  

Is there any way I can determine whether if any other users, computers are forwarding the email via Powershell?  
Is there any way I can find the originating IP?  I currently don't have access to the original email to view the headers.
0
CompTIA Cloud+
LVL 12
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Hi Experts

We are using Exchange 2013 and management wants to know what is the typical message size being sent by users.
They need to know statistics of message for the past 1 month.

I tried running this https://gallery.technet.microsoft.com/exchange/Exchange-2007-2013-email-b66c5543 only for 2 days but it is still stuck in powershell since yesterday.
I got 2 mailbox databases and the size of each is around 600GB, total about 1TB.

Is above link correct to get statistics of the messages daily sent/received? How longs it takes usually for what size of database?

If above is not what I supposed to run, what is the quickest way to get daily messages sent/received for the past 1 week?

My objective is just to get all individual messages size being/sent/received (internal/external).
Any powershell comand that can generate all individual message size for X days ?

Thanks
0
What steps do you recommend for UPLOADING Employee Photos to my Window Server 2016, Active Directory ?

Details
 ** # of employees = 100
 ** photos = under 100kb in size, named firstname_lastname.jpg
 ** AD Account Name = firstname lastname
 ** security = IT (me) will do upload
 ** software = powershell/etc is fine, or something like https://www.codetwo.com/freeware/active-directory-photos
0
Experts,

I have the following code fragment :

Function Test-FileLocation($location, $FileName){
    write-host "Starting File Check for $("$location\$filename")"
        if ($("$location\$filename")){
            write-host "File Exists Proceeding with script"
            $filetest = "True"
        }else {
            write-host "File Does not Exist : FileTest Failed"
            Exit
        }
}

Open in new window


I would like to modify this where I can add Nested Parameter Sets.

For instance in this code I would use something like :

test-filelocation -fullpath "c:\test\somefile.txt"

or

in the same code I could use something like this

test-filelocation -location "c:\test" -filename "somefile.txt"
0
Experts,

What is the easiest way to acomplish the following:

I am looking at turning the following working code into a reusable function.

Function invoke-varcheck2(){
        if ($services.count -gt "200"){
            write-host "Check was successful"
        }else {
            write-host "Variable was not created successfully"
        }
    }
    . invoke-varcheck2

Open in new window



Here was my attempt that was less than successful :

Function invoke-varcheck($varname, $count){
    write-host "Attempting to Test Variable $varname"
        if (($+"$(($varname).count)" -gt $count){ 
            write-host "Check was successful"
        }else {
            write-host "Variable was not Created Successfully"
        }

}
invoke-varcheck -varname services -count 200

Open in new window


Where did I go wrong with this?
1
I have a folder that is used to hold several versions of files.   The main folder contains many sub-folders all named by date.   A particular file can occur in any date folder if it has been revised as it retains the same name.     What i need to do is copy out all the files from this folder structure and get only the most recent version of any file by name ignoring by the date of the file as listed in the OS.
1
Hey

How do I select/Edit:  <member key="1" operator="eq" /> under database "000 name" and "HR Huston" (need to change key from 1 to 2)

Using Powershell
 
<roles>
   <role id="{1234}" name="Unit12">
    <databases permission="allow">
      <database name="000 Name" inherit="true">
        <cube name="HR" inherit="true">
          <dimension name="HR Huston" inherit="true">
            <hierarchy name="HR Huston" inherit="true">
              <forcedcriteria>
                <member key="1" operator="eq" />
              </forcedcriteria>
            </hierarchy>
          </dimension>
          <dimension name="HR Boston" inherit="true">
            <hierarchy name="HR Boston" inherit="true">
              <forcedcriteria>
                <member key="2" operator="eq" />
              </forcedcriteria>
            </hierarchy>
          </dimension>
        </cube>
      </database>
  </role>
</roles>
0
I have several servers low on disk space and need to troubleshoot using Powershell.



Therefore seeking Powershell commands to assist with finding space taken on a local drive.  Ie like Treesize would do.

I would usually use Spacesniffer or Treesize, but our environment does not allow for downloading 3rd party exe files, therefore looking for a Powershell module or commands to do same task.

I already found and tried this Treesize module
https://www.powershellgallery.com/packages/TreeSize/2.0
However it spiked my servers CPU to 98% during use, which is unacceptable for a production server.

Any tips appreciated
Cheers,
String
1
I just discovered the SQLSERVER Module for Powershell and would like to use the.
get-ChildItem2 -Path w:\ -File -Recurse | Select  DirectoryName,Name,CreationTime,LastWriteTime,LastAccessTime,Extension,Length,Mode | Write-SqlTableData -ServerInstance 'sandboxhost' -DatabaseName 'NETAPP_INVENTORY' -SchemaName dbo -TableName 'files' -force

Open in new window

to write to a table.  The data structure is 11 TB with over 100 million files.  

From my initial testing of small directory structures it works well.  My fear is that the system will not be able to hold all the data before writing to the SQL server.  Is there a way to chunk this up or make it more efficient?

Here is what I am doing to help or not:

$Dir = 'W:\'
$DirLists = (Get-ChildItem2 -path $dir -Directory).FullName

Foreach ($dirlist in $DirLists)
{
Write-Host (Get-Date)
Write-Host $dirlist
get-ChildItem2 -Path $dirlist -File -Recurse  | Select  DirectoryName,Name,CreationTime,LastWriteTime,LastAccessTime,Extension,Length,Mode | Write-SqlTableData -ServerInstance 'sandboxhost' -DatabaseName 'NETAPP_INVENTORY' -SchemaName dbo -TableName 'DUMP' -force
Write-Host
}

Open in new window

0
I have a PowerShell script that was created by a former colleague. The idea of the script is to open a word file and compare it to the company official templates. Then, it creates an output data file where we have the compliance information for each file. We have over 3000 Word files, the reason why it is done by a script. However, when we try to run the script now,  it doesn't finish running (it stops in the 300). What I noticed is that the word processes it opens, it doesn't close after, so the CPU gets really busy and I believe that's the reason it stops.

Here's the script as of now:

#to enable powershell scripts on your machine:
# * Run a powershell command prompt as Administrator
# * type this :                Set-ExecutionPolicy Unrestricted

function Select-Folder($message='Select a folder', $path = 0) {  
    $object = New-Object -comObject Shell.Application  
     
    $folder = $object.BrowseForFolder(0, $message, 0, $path)  
    if ($folder -ne $null) {  
        $folder.self.Path  
    }  
}  
$folder = Select-Folder -mess 'Select the folder where the Resumes/CVs are'


cd $folder

$word = New-Object -Com Word.Application
$word.Visible = $false #to prevent the document you open to show
$binding = "System.Reflection.BindingFlags" -as [type]
#$files = Get-ChildItem -filter *.doc
#Just attempt to read all files in the directory
$files = Get-ChildItem
$output = Join-Path $pwd.path OUTPUT.dat

function GetTemplateName {
$word = …
0
Fundamentals of JavaScript
LVL 12
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

How do you give a user full mailbox FOLDER access of another user without managing the permissions in Outlook, so via powershell as an admin.

William.Tell:\Inbox\SharedFolder

Set-MailboxFolderPermission -Identity William.Tell:\Inbox\SharedFolder -User Joe.Smith@contoso.com -AccessRights Owner wont allow the Joe Smith to expand the folder.

I don't want to give Joe Smith any access to view any other content other than whats in that specific folder.

Thanks in advance
0
Hi,

I just need update about O365 in hybrid mode with On-Premise Exchange. Two years ago I remember that some permissions like "send as" is not working if the concerning mailboxes are not in same side (one is on premise and other on O365). I heard that this issue has been fixed or improved now. Is that true? Just out of curiosity which Powershell cmd should be run to give "send as"permission?

Thanks
0
How to extract NTFS Disk Security user list which was added in a disk using command prompt
0
Hi,

Is there a way by GPO or PowerShell to remove a specific printer driver package in windows 7 and Windows 10?

Thanks
0
How do you use PowerShell to copy all files in a directory (with all sub-folders) on the drive to another drive?

For example

xcopy c:\test\*.* d:\test /s
0
Building off of https://www.experts-exchange.com/questions/29131838/Search-CIDR-subnet-ranges-with-powershell.html
I'd like to have a second file with known entries be searched first, then search the CIDR.csv failing a result on the main fields. I'd like to search on the main fields, IP, Host and User
Inventory.csv
IP_Address(s), Hostname, User, Notes
10.1.2.3, Workstation003, Jane Doe, HR Admin
10.10.0.3/1.2.3.4, Workstation001, John Doe, IT Analyst
10.1.2.30, Workstation007, James Bond, Janitor
10.69.69.23, WorkstationNiner, Tommy Boy, Sales
10.10.0.4, Workstation002, John Doe, IT Analyst

Open in new window


In the above, searching based on User "John Doe" should have two results (on two lines)
.\finddetails "John Doe" (maybe switches are needed? Like -i = ip, -h=host, -u=user?)
IP_Address(s), Hostname, User, Notes, Subnet
-------------- -------------- -------------- --------------
10.10.0.3/1.2.3.4, Workstation001, John Doe, IT Analyst (Production, unknown)
10.10.0.4, Workstation002, John Doe, IT Analyst

Open in new window

(Production)
[/code]
./finddetails 10.8.0.9
IP_Address(s), Hostname, User, Notes, Subnet
-------------- -------------- -------------- --------------
10.8.0.9, ???, ???, Telco, 10.8.0.0/24

Open in new window

Something to that effect if that makes sense? If the IP doesn't match anything, then some nice error :)
Let me know if you have questions on the details, thanks!
-rich
1
Hello,

Looking for help in searching for email via PS based on specific criteria and/or range.

Date range from to to
recipient : address known
subject: wild card use to match "*fishing*" or "*water team*"

Get-messagetrackinglog -ResultSize Unlimited -Start "12-16-2018 7:00:00AM" -End "12-18-2018 10:30AM"  -recipients:jdoe@domain.com | where{$_MessageSubject -like "*fishing*"| select-object Timestamp,sourcecontext,source,eventID,MessageSubject,Sender,{$_.Recipients} | format-table  

Above doesn't work for just one subject wildcard, while I haven't even gotten to include the 'or' other criteria yet.

Some assistance on syntax would be truly be appreciated.  Note on premise 2010 Exchange. Thank you.
0
Is there a way via Powershell that would allow me to export messages deleted by a user to a PST File.

I have a situation where we need to gather deleted emails as evidence from an active mailbox.

The command would
  1. Query the mailbox for hard deleted items
  2. Export just these to a PST file
0
Hi,

I have 2 same printers shared from Windows 2012 server. One is working but not the other. Is there a way to copy printer setting between 2 printers?

Thanks in advance
0
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Hi,

Is there a tool to read and modify NTUSER.DAT file?

Thanks
0
I need to clean up a number of hard drives that contain different back ups / downloads of files and folders.  It's a mess. Is there a synchronizing program that will examine what files are duplicates so that I can clean it up?  Hardly a tech question but it seems a common problem.
1
I'd like to be able to search for an IP's within CIDR ranges/list, and output the information around that IP's CIDR file.
Very similar to this EE question https://www.experts-exchange.com/questions/29127048/Excel-CIDR-IP-Address-Overlap-Formula-Check-for-CIDR-IP-Address-Overlap.html

This is what I envision...
CIDR.csv
CIDR, Subnet_Name
10.0.0.0/24, Guest Network
10.10.0.0/23, Production
10.8.0.0/22, Telco
10.69.69.0/24, BoomChickaWowWow

Open in new window


.\findip.ps1 10.0.0.22
    Found: 10.0.0.22 - Guest Network 10.0.0.0/24

.\findip.ps1 10.8.0.123, 10.69.69.68, 10.1.2.3
   Found: 10.8.0.123 - Telco 10.8.0.0/22
   Found: 10.69.69.68 - BoomChickaWowWow
   Not Found: 10.1.2.3

FindIp would look inside the cidr.csv and then expand the CIDR's and seqrch for matches within.
1
We have an employee who has taken unapproved leave and taken her company issued iPad tablet with her.

The Dept head has a strong suspicion that the employee is using the tablet in ways that are a concern.

What sorts of usage information can be obtained in Exchange 2016 via Powershell for things like dates/times of emails being read, emails being sent.

Because the device isnt using Activiesync (being an Apple) I suspect the stats PS provides about ActiveSyn transactions wont be any value.
1
Environment: Exchange 2013

Goal: I would like to see all of the ActiveSync device serial numbers (or IMEI's) within my Exchange environment.  

Back Story: I was given a serial number of "12345" by a colleague and I need to determine who is using that phone within our organization.  So I was thinking of compiling a list of all serial numbers and finding it within the list.

Does anyone know a Powershell command to do this?

Thank you for your time!
0
Hi All

I am trying to bulk add guest users to Microsoft Teams using a CSV file and not having much luck.

I have the powershell script to bulk add different teams but I don't want to add the users as part of this process as I plan to add/remove guest users on a daily basis.

Regards

Si
0

Powershell

18K

Solutions

8K

Contributors

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.