Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources

Robocopy

0
0

Hi I am trying to write powershell script for robocopy .

Requirement as below example 

Source(Server1)                Destination ( Server2) 

c:\backup\1                          d:\backup

c:\backup\2                          D:\backup

 

wrote script it works but now user requested some additions

Like 

 

Source 

c:\backup\1                          d:\backup\1 and other folder in same place like d:\backup\1_1 

c:\backup\2                          d:\backup\2 and other folder in same place like d:\backup\2_1

 

if i use more than one robocopy command it doesn't work , I am not great at powershell any help will be much appreciated 

 

 

 


SPO : PowerShell to get Custom Actions in a Site Collection

Searching by file Type

0
0

Hi All,

I'm writing a script to delete files from a folder, that are more than 24 hours old.  What I'm looking for though is a way to specify the file type?  Like for example if I want to specify only .ps1 files, is there a good method?  Or a good location I can look to for something to read? 

Thoughts appreciated.

Uninstall Script - spaces in cmd-line arguement?

0
0

Good Morning all,

I have the following script I found on the Internet somewhere and it works great unless there are spaces in the path to the program, how do I make sure my variable is expanded and also that cmd treats the path as one long string?

$javaVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall  |

    Get-ItemProperty |

        Where-Object {$_.DisplayName -match "java" -or $_.Displayname -match "J2SE"} |

            Select-Object -Property DisplayName, UninstallString

 

ForEach ($ver in $javaVer) {

 

    If ($ver.UninstallString) {

 

        $uninst = $ver.UninstallString

        $uninst = $uninst.Replace('/I','/X ')

        & cmd -ArgumentList "/c $uninst /quiet /norestart"

        }

}

It is this line that fails if there are spaces in the path:

 & cmd -ArgumentList "/c $uninst /quiet /norestart"

Thanks for any help

 

 

Azure Storage PowerShell v.1.7 – Hotfix to v1.4 Breaking Changes

0
0

Breaking changes were introduced in Azure PowerShell v1.4. These breaking changes are present in Azure PowerShell versions 1.4-1.6 and versions 2.0 and later. The following Azure Storage cmdlets were impacted:

Read More

What does Microsoft PowerShell’s availability on Linux means to enterprises and CIOs?

0
0

Microsoft PowerShell’s latest Linux move will help enterprises in software development, its manageability and dealing with interoperability in today’s heterogeneous environment

Read More

Windows 10 Anniversary on a Raspberry Pi: Another look at IoT Core

What’s New in SQL Server 2016 Analysis Services

0
0

When Microsoft first included OLAP Services (the precursor of today’s SQL Server Analysis Services) in SQL Server 7, the company totally changed the enterprise database landscape. The introduction of OLAP Services marked the first time that OLAP (online analytical processing)/business intelligence analysis capabilities were bundled with an enterprise relational database, and it was one of the driving forces that transformed BI from a niche IT role to mainstream database technology.

Read More


Poisoned Word docs deploy rogue web proxies to hijack your encrypted traffic

0
0

The new attack uses Word documents loaded with malicious code

Read More

Beyond the console: 3 supplements for Office 365 admins

0
0

 

There are times you need to use a different tool to manage Office 365. Here are three you should know

Read More

 

 

Manage Folders Using A Date

0
0

I have some folders which are named with the following date format 'YYYYMMDD' i.e. 20160902 representing Sept 2nd 2016.  I want to delete a folder that is 6 months old including all of its content. I'm able to calculating a date i.e. (Get-Date).AddDays(-150) or I can format the current date (Get-Date -Format FileDateUniversal). (after I get a formatted date, I strip off the last character "z" to get just 20160902). My problem is getting some date in the past, and get it formatted as a string such as YYYYMMDD so that I can use the string to search for and then delete old folders.  I've also tried working with formatting a date with the following....

Get-Date -Format "yyyymmdd" 

What is odd to me with the above cmdlet, is that my latest result or output is 20160702.  I don't know where 07 ( in 20160702) is coming from, but I've gotten different numbers in place of 07 when I've run that cmdlet at different times. I've gotten 10, 33, 52, so I don't know what is going on there.

Is there any way I can calculate a date, 5 or 6 months in the past, convert the date into a string with the format of YYYYMMDD and then use that string or format to search for the folder and delete it if it exists?

Thank you for any assistance,

Dean

PowerShell – How to copy a local file to remote machines

0
0

During a training, a student asked me how to copy a local file to remote machines without using fileshare. It was a great question, so I decided to share here in this post.

Read More

Microsoft fixes PowerShell problem caused by Windows 10 Anniversary update

0
0

Microsoft's latest Cumulative Update to Windows 10 Anniversary, released August 31, includes a fix awaited by some using PowerShell.

Read More

Latest Windows 10 CU Delivering to Squash Freeze Bug and Fix PowerShell

0
0

For many of you, you’re waking up to a brand new cumulative update for Microsoft’s latest public revision of Windows 10 – the one delivered as an Anniversary Update just a month ago.

Read More

Microsoft Said To Fix PowerShell Problems with Latest Window 10 Update

0
0

Microsoft is now giving an all-clear signal, of sorts, with regard to PowerShell issues caused by a late August Windows 10 update release.

Read More


RM 2015 – Execute Remote PowerShell Task Failing with Failed to Install VisualStudioRemoteDeployer

0
0

Just worked a support case with the customer using the RM task, Execute Remote PowerShell command on a Windows Server 2012 R2 server and seeing the following error message on a deployment:

Read More

PowerShell.com Community is Now a Part of the IDERA Community

0
0

Hey Everyone -

We have been in the process of migrating all of the content and user profiles over to the IDERA community and that is now finalized. You can now access your account on that site with your same user credentials as you do the PowerShell.com community.

Once you login, you will notice that you can easily contribute, ask and answer questions, and work your way up the leaderboard.

I should note that PowerShell.com will be read-only starting on Sunday September 11th. You will need to login to the new community to create new content.

If you have any questions please send liz.stephens@idera.com an email.

Thank you,

Liz Stephens

Microsoft Launches Bug Bounty for .NET Core, ASP.NET Core

0
0

 

 

Microsoft announced a bug bounty program for developers to find bugs in its .NET Core and ASP.NET Core runtime and web stack.

Read More

 

Transforming Data with PowerShell Classes, Part 1

0
0

I hope you’ve been enjoying this series on working with data in PowerShell.

Read More

Making Data Dance with PowerShell

0
0

I think what you’ll learn in this article is going to be fun. Because of PowerShell’s emphasis on working with objects, once you get your head around that idea, you’ll realize PowerShell is a terrific tool for managing just about anything. I use PowerShell for all sorts of what you might consider non-IT tasks from a simple task management system to a tickler program with popup reminders.

Read More

Dancing on the Table with PowerShell

0
0

PowerShell doesn’t really care where the data comes from or what it looks like. Once you have turned the data into objects, your options are practically unlimited.

Read More

Question on Functions

0
0
I have created a function called Uninstall-Software. I created 2 param at the top

functionUninstall-Software
{
param
(
[string]
$ComputerName='',

[string]
$Remove=""
)

This is followed by code. From the bottom of my PowerShell ISE window, at the PS C:\> prompt I can type inget-helpUninstall-Software. It returns the following.

NAME
Uninstall-Software

SYNTAX
Uninstall-Software [[-ComputerName] <string>] [[-Remove] <string>]


ALIASES
None


REMARKS
None



From the bottom of my PowerShell ISE window, at the PS C:\> prompt I can type inUninstall-Software-C (it will autofill in ComputerName) -R (it will autofull in Remove)


But when I try to call this function with this command I get the error below.


$pc=Read-Host"Enter remote computer name"
$remove1=Read-Host"Enter software to uninstall"
Invoke-Command-FilePath"\\server1\PSScripts\UninstallSoftware.ps1"-ComputerName$pc-Remove$remove1


PS C:\> C:\Dropbox\Scripts\PowerShell\Functions\Call Uninstall Software Function.ps1
Enter remote computer name: cclab3
Enter software to uninstall: snagit
Invoke-Command : A parameter cannot be found that matches parameter name 'Remove'.
At C:\Dropbox\Scripts\PowerShell\Functions\Call Uninstall Software Function.ps1:7 char:94
+ ... 01\PSScripts\UninstallSoftware.ps1" -ComputerName$pc-Remove$remove ...


why?

Azure August Roundup: New high-performance compute instances and more

0
0

PowerShell has gone open source and Azure Stack is on its second tech preview, too.

Read More

Powershell Script that checks for out of date definitions and sends an email out

0
0

Just sharing this as someone may need it one day.  Although this can be done by scheduling reports on SEPM, we had a need in house to manually set this script out via group policy on workstations to send an email out to thelpdesk.  Below is the script, it runs, checks the defination directory date and if it is older than 30 days, sends and email out. 

Read More

Data Transformations with PowerShell Classes, Part 2

0
0

I’m having fun with this series and hope you are as well. In my previous article, I introduced you to PowerShell classes and I built a class that I can use with my movie data file.

Read More





Latest Images