Powershell

15K

Solutions

55

Articles & Videos

7K

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

Hello,

I have a variable named $Data which contains multiple dates in the format "28-02-2017" (DD-MM-YYYY) which I need to convert to the format of 06/28/17 (MM/DD/YY). How can this be achieved?
0
Free eBook: Backup on AWS
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Can someone please explain the code below in depth. I am trying to understand how the new folder creation is being identified by the code? Also does the script run once to find the new folder and the stops?

-------------

#requires -version 3
$basecount = (get-childitem -Path \\server1\Temp -Recurse -Directory).count
do {
  Start-Sleep -Seconds 300 # 5 Minutes
  $count = (get-childitem -Path .\ -Recurse -Directory).count
  if ($basecount -ne $count) {
      Write-EventLog -LogName Application -Source "FileWatcher" -EntryType Error -EventID 1  -Message 'Directory has been Created'
      $basecount = $count
  }

} while ( 1 -eq 1) #infinite loop
0
Hi Experts,

I had this question after viewing Without using Invoke-Command in powershell.

If I do a setspn -d http/<servername> and then do invoke-command remotely into server it works.

Every time I remote execute a powershell I need to do setspn -d and then perform script action and then setspn -A to reinstate the setting.

Is there something which I can do one time such that it will allow the setspn to be in the server as well as allow PSRemoting?

Please let me know

Thanks
0
Is there a way to give users permissions to a shared mailbox giving them the ability to READ and MOVE items to folders, but not delete?

Thanks
0
Need to get the admin groups names for which a determine user is part of, even if the admin group is being inherited.
0
We work with a vendor that requires us to use one of their certificates.  When we install it on out core 2016 server, the certificate is not used because "The CA root certificate is not trusted because it is not in the trusted root certificates store"  (But it actually is.)

One solution we have is to go into the local computer policy object (Server is in a workgroup) go into computer configuration/windows settings/public key policies and set the certificate path validation settings.  Since this is core we use RSAT, open MMC remote into our server, open the local policy object for that machine, and the public key policies are missing from that local group policy.

Also we can't use the powershell local policy commands, because they are not installed, and when I attempt an install it is not an available module.
0
Hi.
I need a help, I have two files, file1.csv with three columns (name, surname, profile) and file2.csv with the same columns (name, surname, profile), I am trying to compare if file1.csv is equal to file2 .csv. The data of each file are not in the same order:

File1.csv
Name      surname      profile
Mary        McCoy         Receptionist
Peter       Robert         Auditor
Susan      Parker         Logistics
Richard    Sarandon    Administrator

File2.csv
Name      surname      profile
Richard    Sarandon    Administrator
Mary        McCoy        Assistant
Susan      Parker        Logistics
Peter        Robert       Auditor
Sergio      Alaves       Systems

I would like to be able to compare each line of the file1.csv with all the lines of the file 2.csv and verify if they are the same, to indicate me in which column there are differences. With this scripts does not work for me:

Compare-Object -ReferenceObject $ (Get-Content C:\ file1.csv) -DifferenceObject $ (Get-Content C:\ file2.csv) -IncludeEqual

Or

diff (cat -Path "C:\file1.csv") (cat -Path "C:\file2.csv") -IncludeEqual | Export-Csv C:\Compare.csv -NTI

Could they help me?
0
Hi Experts,

I want to get the remote computer hostname from powerhshell as when i use $env:COMPUTERNAME I am getting my local machine hostname. Below is my script to get the list of installed software from the remote machine and i have a list of hostnames/IP in a txt file. Why am i asking for this is sometimes I use IP to get this list of software installed , so i need the remote hostname as well. As you can see below in my script, i need the hostname to be in the for-each object section below to replace the $env:COMPUTERNAME

 
foreach($pc in $computers){$properties = "name", "vendor","version" ,"installdate"
Get-ChildItem HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\*\Products   | ForEach-Object {
    $root  = $_.PsPath
    $_.GetSubKeyNames() | ForEach-Object {
        try {
            $RegKeyPath = (Join-Path -Path (Join-Path -Path $root -ChildPath $_) -ChildPath InstallProperties)
            $obj = Get-ItemProperty -Path $RegKeyPath  -ErrorAction Stop
            if ($obj.UninstallString) {
                [PSCustomObject]@{
                    Path = $RegKeyPath;
                    Name = $obj.DisplayName ;
                    Vendor = $obj.Publisher  ; 
                    Version = $obj.DisplayVersion ;
                    InstallDate = $obj.InstallDate ; 

                   
                } | where vendor -like 'microsoft*'
            }  
        } catch {
        } 
    } 
} | ForEach-Object {
    '{0},{1},{2},{3},{4}' -f 

Open in new window

0
Hey

I need to write a date to registry

Next run:

If the date is more than 24 hour from current date - do something.

Thx in advance
0
Hello,

I want to add an active directory account to the local esxi servers through powercli.
The user has to have shell access and should be in the local group "read only"
Im running esxi 6.0

I have tried the following but i cant get it working
New-VMHostAccount -UserAccount user@domain -GrantShellAccess $true

it keeps asking for a password which i dont want to give as it is a domain account.

Thanks
0
Does Powershell have you tied up in knots?
LVL 6
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

I need a powershell script that can force logoff multiple users on multiple computers.

Lets say i have a csv file with 2 columns(servername, user)
Example: server= server 1, users=sa.user, sa.user1
server=server2, users=sa.user, sa.user1, sa.user2

Note: Don't need to to know how to get the list of server/s and user/s because I already have a separate script for that.
0
Need assistance with a powershell/vbs script to do the following:

We need to monitor the following path \\SERVER\folder.  When a new folder is created that's an indication of a failure of a background process. Once the new folder is detected we need to send an email alert. We are looking to received the alert only when newly created folders (now-15 minutes or so)or just the last date (compare with the most recent folder date creation) if newer then sent alert.

We do have SCOM and so we might run the script from there otherwise from the server itself (windows server)

Can you someone please assist
0
I trying to run a script to clean up a server and I'm getting the attached warning.   How to I get it to run?
I'm not that familiar with PowerShell so please give step by step instructions.  I'd appreciate it.
powershell.jpg
0
I would like to be able to run commands from a windows machine (using some tool ) and run commands in linux machine and retrieve results of those commands.
I have a powershell code which connects to remote windows systems, I want to be able to retrieve system info from linux machines as well. Is this possible?

This is in relation to this question:
 powershell to linux.
0
This is what I came up with in powershell but it doesn't list the actual users, or exclude people with just 'Domain Users'

Get-ADUser -Filter {Enabled -eq $false} –Properties MemberOf | Select-Object -ExpandProperty MemberOf | Get-ADGroup -Properties name | Select-Object DistinguishedName,name,GroupCategory

Open in new window

1
Hello Experts,
In continuation to : https://www.experts-exchange.com/questions/29014655/Powershell-help-for-creating-accounts.html
I have a further enhancement request,
I have 2 Columns in SQL
ADGroup & O365Group

These columns contains values, which are separated by comma (,) these are existing groups in AD & O365
I want them to be integrated into the script so that when the new user is created he is added to the respective groups in both the places.

Thanks in advance.
A
0
Install a .exe file (MS Patch) using PSEXEC as Admin on multiple servers

Any help is appreciated.
0
HELP!!!

Using powershell how can i multiply a number by -1? In attached file that looks like this. I need to multiply the numbers after the 3rd comma by -1. So if its a negative, make it a positive, and positive a negative.

H,20170620230011,1,19551,20170620230011
004,2017-06-20 00:00:00,0001450002100,-1,SupplyRejects,1000037,EA
004,2017-06-20 00:00:00,0001500007553,-1,SupplyRejects,1000038,EA
004,2017-06-20 00:00:00,0001800000210,-8,SupplyRejects,1000038,EA
004,2017-06-20 00:00:00,0001800000216,-1,SupplyRejects,1000038,EA
004,2017-06-20 00:00:00,0001800000235,12,SupplyRejects,1000038,EA

resulting output should look like this.
H,20170620230011,1,19551,20170620230011
004,2017-06-20 00:00:00,0001450002100,1,SupplyRejects,1000037,EA
004,2017-06-20 00:00:00,0001500007553,1,SupplyRejects,1000038,EA
004,2017-06-20 00:00:00,0001800000210,8,SupplyRejects,1000038,EA
004,2017-06-20 00:00:00,0001800000216,1,SupplyRejects,1000038,EA
004,2017-06-20 00:00:00,0001800000235,-12,SupplyRejects,1000038,EA
0
Hi  

How to automate the powershell I have created the task schedule but not able to trigger the task

powershell.exe  –Noninteractive  –Noprofile  –Command “ &{<C:\Users\Alan.lam\Downloads\FileSystemWatcher.ps1" in Add arguments.
0
Optimizing Cloud Backup for Low Bandwidth
LVL 1
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Hi All,

I’m in the process of migrating the mailbox from one Exchange Server 2013 Sp1 to another 2013 Sp1 (no-DAG) using the batch migration PowerShell.

I can see it from the Exchange Control Panel website, there is the batch process migration status, however, I need to mount and dismount the mailbox database in the new server due to removing the quota implementation, what’s the impact in pausing or STOPPING the batch migration which caused the migration process to become SUSPENDED ?

Can I still resume it again after mounting the mailbox Database in the destination server ?
What’s the impact to the users when the migration process is STOPPED or in the SUSPENDED state ?

I’m not going to delete the migration batch (by clicking the bin icon) since I need to get off from the old server to the new server.

Any help and comments would be greatly appreciated.

Thanks.
0
Hi All,

Can anyone please assist me in correcting the below PowerShell script to properly display the size of Exchange mailbox database size total in GB ?

Get-MailboxServer | Get-MailboxDatabase | Select Server, Name,@{n='MailboxesCount';e={@(Get-Mailbox -database $_.identity).count}}, @{Name="Size (GB)";expression={"{0:N2}" -f ((get-mailboxstatistics -database $_.Identity | Measure-Object -Property TotalItemSize,TotalDeletedItemSize -Sum |Select-Object Sum |Measure-Object -Property Sum -Sum).Sum.ToString() /1gb)}} | ft -AutoSize -Wrap

Open in new window


Because when I run the script it is only showing the count but the size is just all 0 bytes ?
Would it be possible to show the GB free of the disk space where the .EDB file is located.

Thank you,
0
New to  powershell

Would like a script that lists files past a certain age.  Would like to display folder name and have paging if possible

Thanks
0
New to powershell

Looking to create a powershell script that will delete all files in folder and sub folders past a certain age.

Thank you
0
This is s SBS 2011 Standard
Found out today that a client can't access email. A colleague jumped on the Server and found all the exchange services disabled, he enabled them and mail worked for a short time. Mail not longer works, here are the issues I have found.
Exchange management console shows this error
Connecting to the remote server failed with the following message : The client cannot connect to the destination specified in the request.  Verify that the service on the destination is running and is accepting requests.  Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM.  If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". 

Winrm shows everything is fine.
Strange things I have noticed, Update rollup 4-14 for Exchange server 2010 SP3 all installed with todays date. In the programs list Microsoft Exchange server 201 is showing an install date of today. I have all the services running for exchange.
When I hit "change" on exchange server it says "The LPVersioning file has an invalid value. Please check the Exchange Log for more info.
I also can't open the "Turn Windows Features on or off" it just opens Services.
What the heck happened last night?
Running SFC now.
0
Hi there,
I am in an environment of 400 users.
Desktops get reissued to users regularly. When the desktop gets given out for the first time it is imaged using MDT. When the computer is handed to another user, the support guys have to go along and reconfigure the computer for the next user. I know it sounds like you could reimage it but the company I have just started with doesn't have everything in the image, so it is a much bigger job to reimage the computer.
So part of preparing the computer for the next user is changing the Windows 8 and Windows 10 start menu tiles back to the standard company way. the business doesn't want to lock down the start menu but wants the highly paid professionals that use the computers to start off with the most likely to be useful things in the start menu, and then leave the users to alter it as they see fit from there.
The users have roaming profiles.
I would like to help the support team be able to push the start menu back to the desktop using powershell or something like that.
I found in powershell the commands export-startlayout and import-startlayout, but it doesn't work on roaming profiles as far as I can see. That is what Microsoft says and it seems to be right. I tried it on computers not joined to the domain and it works fine.
I can see group policy is capable of it but the users need to be allowed to change it too.
Do you have any other ideas?
Thanks,
Shaun
0

Powershell

15K

Solutions

55

Articles & Videos

7K

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.