Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all 6937 articles
Browse latest View live

Use PowerShell to check for illegal characters before uploading multiple files into SharePoint

$
0
0

If you have done any sort of bulk file uploading into SharePoint, you will be aware of issues with file names containing illegal characters. These files can disrupt the uploading process, potentially causing many hours of frustrating and time consuming tasks examining and repairing file names.

Read More


Pinging???

$
0
0

Normal 0 false false false EN-AU X-NONE X-NONEHow would I write a powershell script to ping a range of IP addresses and check if the device is reachable?  I need to know the status of the reachable devices in the specified range, and display the total number of reachable devices.

Serial Connection

$
0
0

Good morning,

I struggle to connect via serial to Cisco switch, send commands and print the output to prompt   using Powershell, but until now everything I tried resulted failure or Powershell freeze.

 

Has anyone tried this?

 

Thank you

 

 

 

 

Updating all user AD settings in a loop - error checking

$
0
0

Hi All,

I've been given a list from HR of: FirstName, Surname, Username, Title. The username field I've generated based on first initial + surname from the list. I need to import the titles into AD.

My concern is that there will be instances where the username generated from the HR list doesn't match the username in AD, for example if there is already a user in AD for Joe Bloggs called jbloggs, then if we get a 2nd user called John Bloggs their username might be jobloggs. In which case I assume the script will just fail.

I've written and tested the following code which is working when using 2 staff that I know usernames match between the HR list and AD:

$HcList = Import-Csv -Path Z:\Scripts\PS\AD\JobTitle\test_titles.csv
$HcList | ForEach-Object {Set-ADUser -Identity $_.username -Replace @{Title=$_.Title}}

Any tips on how I might add in error checking, that is, I basically just want to bypass any in the HR list that don't directly match an AD username and allow the script to continue to loop with the rest of the users that do match without failing out to an error message.

Thanks guys!!

searching AD

$
0
0

I have this code that works.

$search= [System.DirectoryServices.DirectorySearcher]$root
$search.Filter="(cn=$computer)"
$result=$search.FindOne()
$computerToMove= [ADSI]$result.path

It is part of a script that moves your computer to a specific OU within AD.   I have Googled around on how to query the AD "JetDatabase" There is a lot out there but what I have not found yet is where do you get a list of commands to use within PowerShell.   Example:   In PS we can type get-help get-process -examples

In PS how do you find out all AD commands like System.DirectoryServices.DirectorySearcher or [System.DirectoryServices.ActiveDirectory.Domain]::

is there a command that will show you this with examples?  

Querying Network Connection detailed view

$
0
0

Hi, hoping for some help for a Powershell newbie

Using Powershell and WMI cmdlets, how do I query the information shown in the columns in Network Connections detailed view (see screenshot below), in particular the columns, Status and Network Category.

I've looked through Win32_networkadapter and win32_networkadapterconfiguration but I cant seem to find the corresponding information. I've also been trawling through WMI Explorer to see if I can find the same information but no luck so far

Any assistance is appreciated.

Newbie Kickstart for XML and CSV

$
0
0

Hi guys,

Apologies in advance as I'm relatively new to powershell.

I have an XML file and from this file I pull in some data and can successfully send this to a text file. However I'd like to manipulate the data by mutiplying by a fixed number and sending it to a CSV that I could append with the output from another number.

Is my approach that follows correct or should I be doing something else?

[xml]$xmldata = Get-Content data.xml
$xmldata.tree1.total > outfile.txt

#up to here, I'm good, this works

#what follows does not work

$xmldata.tree1.total > $xmldata_object1
$xmldata_object1 = [int]$xmldata_object1/1024
$xmldata.tree2.total > $xmldata_object2
$xmldata_object2 = [int]$xmldata_object2/1024

#if I try to write-host or write-output of $xmldata_object1 or $xmldata_object2 it fails as does any attempt I try for CSV.

 

Strangeness in getting ACLs for .pst files

$
0
0
Hello everyone.

I have the need to determine the ACLs for a range of files and have found code-snippets and such that have helped and for the most part seem to work well. However, one thing is beyond me at the moment:

1) Get-ACL: Get-Acl on a .pst file, it gives me an error, no matter the location of the file, whether it is open in outlook or not, no matter of size or such things. I can see the file with Get-ChildItem, and indeed using icacls at the command line or the Windows Explorer Properties menu, I can get the acl information. So acl info is there and exists. But when I try the get-acl command, I get the following:

PS C:\users\Shadow\Desktop> get-acl '.\PersonalFolders.pst'

get-acl : Attempted to perform an unauthorized operation.

At line:1 char:1

+ get-acl '.\PersonalFolders.pst'

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [Get-Acl], UnauthorizedAccessException

+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetAclCommand

As part of experimenting, I tried the get-acl command against a text file that had the pst extension, and it didn't work.   I renamed an actual pst file with another extension (such as .pdf) and it worked. 

I also tried the GetAccessControl command and it worked when applied to a non-pst file, such as:  (get-item 'f.pdf').getAccessControl().Access

However, if it was a pst file, such as (get-item 'f.pst').getAccessControl().Access, it bombed with:

Exception calling "GetAccessControl" with "0" argument(s): "Attempted to perform an unauthorized operation."

At line:1 char:2

+ (get-item '.\f.pst').getAccessControl().Access

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException

+ FullyQualifiedErrorId : UnauthorizedAccessException

Suggestions? Thoughts?

Thanks in advance,

W


Microsoft Releases PowerShell Module for Data & User Management, System Settings in Dynamics CRM

$
0
0

Co-created by Microsoft's Kenichiro Nakamura and Sean McNellis, the Microsoft.Xrm.Data.PowerShell module is a single PowerShell module with over 60 PowerShell functions to perform data operations in Dynamics CRM and manipulate user and system settings. While some of these actions were possible already using the official CRM PowerShell cmdlets, they required using multiple PowerShell snap-ins.

Read More 

Modifying user description

$
0
0

I am having trouble finding a script for modifying the description field for user accounts in Active Directory.

For example the description field has:

Oldname, 1234567

and it needs to be changed to:

Newname, 1234567

Keeping the last part of the description field.  The last part of the description field "1234567" will vary base on user, but should for the most part, have 7 characters at the end.

I have researched trimStart(), but am not quite sure how I would implement that for a script.  

Any help would be appreciated!

Art of Automation: Leveraging PowerShell Modules and Starting with Office 365 PowerShell

$
0
0

Recently I published an introductory article about how PowerShell can help transform your business.   The article provided a primer to start learning the PowerShell language.   You can read the article here: 

Read More

PowerShell is King–Invoke-EXE could help you run .EXE using PowerShell

$
0
0

During today’s Management Masters I did a demo on how and why to use application wrappers, in one of the demos I showed a function called Invoke-Exe and I thought I did publish that long time ago, but I did not, so here it is. Actually, there is two versions of this. One that always return the exit code from the app and then you can use that for conditioning, the other one checks that the return code is what you told it to be and if not it throws an error.

Read More

Powershell Script to Update GAL (Global Address List)

$
0
0

We all know that the OWA page (ECP in purticular) has the option to update the user contact information. However, at time you might in need for a script to enable the similar feature, such as when the OWA feature is not available to all user. I had similar situation in my company, where the OWA feature is not enabled for ALL users, and forced to develop a small PS script which enables the users to update their on contact information self.

Read More

Azure, PowerShell and DLL hell

$
0
0

It’s great that Azure is supported so extensively within Windows PowerShell – it really helps with automating builds and adopting a continual delivery / DevOps approach however eventually, in my experience, you’ll find yourself wanting to supplement what’s available from Microsoft with some Cmdlets of your own. Sure you can access .Net from PowerShell but sometimes C# is just more expressive and maintainable.

Read More

Uploaded CustomizeWindows10 Module to PowerShell Gallery


Finding Lost Windows Product Key Using Command Prompt Or PowerShell

$
0
0

In this article we will go through some different methods by which we can find our lost Retail Product Key of our Windows 10/8.1 using command prompt or PowerShell from BIOS/Registry.

Read More

Copy Multiple Files to Remote servers

$
0
0

Hi ,

I need a help to Copy Multiple files to remote servers .. Basically I had created a Schedule Task

in windows 2012 server and had export it to xml  so need to copy 2 bat files  and one xml files to multiple servers and then create a Schedule task by Importing XML .. Can any one please help ..

Here is the script i had try but it give me error also did not find any help  to create a Schedule task by Importing XML on Remote computer and create a schedule task

$computers = gc "C:\scripts\computers.txt"

$source="c:\windows\temp\test.XML","C:\windows\temp\File1.bat","C:\windows\temp\File2.bat"

$dest = "\\c$\windows\temp"

 

foreach ($computer in $computers) {

 

    if (test-Connection -Cn $computer -quiet) {

 

        Copy-Item $source -Destination \\$computer\$dest -Recurse

 

    } else {

 

        "$computer is not online"

    }

 

}

Modifying user description in AD

$
0
0

I am having trouble finding a script for modifying the description field for user accounts in Active Directory.

For example the description field has:

Oldname, 1234567

and it needs to be changed to:

Newname, 1234567

Keeping the last part of the description field.  The last part of the description field "1234567" will vary base on user, but should for the most part, have 7 characters at the end.

I have researched trimStart(), but am not quite sure how I would implement that for a script.  

Any help would be appreciated!

 

Recursive Delete Script Returns 'Specified Method Is Not Supported'

$
0
0

I have the following cleanup script, pretty simple to delete files older than 90 days.  The script works on two other folder paths in the same drive letter path on the same server.  This one, however returns the, "Specified method is not supported" error.

The two folders that this worked on had just over 200 and 350 files.  The folder this is not working on has 1099 files in it.

$Path = "E:\MyServerNameShare\File_Archive\IDI_Archive"
$Daysback = "-90"
$CurrentDate = Get-Date
$DatetoDelete = $CurrentDate.AddDays($Daysback)

Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item

Any assistance would be highly appreciated - Thank you.

Copy-Item - behaviour changes on subsequent runs of the script

$
0
0

Good Afternoon all Smile

I have a script whereby I want to copy items in a folder from one directory to another.  The script works the first time but then behaves differently subsequent times by recreating the source folder again, how do I stop this behaviour please?

[string]$FolderName = Get-Date -f dd

$SourcePath = "\\server\folder1\folder2\"

$DestinationPath = "\\server\folder1\"

Copy-Item -Path $SourcePath -Destination $DestinationPath\$FolderName -Recurse -Force

Viewing all 6937 articles
Browse latest View live