Copy, Move, Delete files with PowerShell

Поделиться
HTML-код
  • Опубликовано: 2 авг 2024
  • In this video, we get back to the basics of working with files on the filesystem using PowerShell. We look at some aliases, copy files, move files, and remove files. We also look at how network file shares roll into the fold. Fun, foundational stuff.
    Cmdlets covered:
    * copy-file
    * move-file
    * remove-file
    For support, training, or more information about PowerShell check out www.boldzebras.com
  • ХоббиХобби

Комментарии • 214

  • @ersinbostanc3365
    @ersinbostanc3365 6 лет назад +6

    By far the best powershell training video on youtube! Very clear and understandable. Hats off to Shane!

    • @ShanesCows
      @ShanesCows  6 лет назад

      You are too kind. Thank you.

  • @mrclaytron
    @mrclaytron 7 лет назад +8

    Great videos Shane. I'm a senior Web Developer, but a total noob when it comes to PowerShell... Your videos are really clear and concise... I'm looking forward to using PS to improve my builds and workflow... I should have got into this years ago! Good work... Cheers!

  • @butchgavaletz9130
    @butchgavaletz9130 4 года назад +3

    Shane, as an absolute rookie to PowerShell, your videos are fantastic, keep them coming

    • @ShanesCows
      @ShanesCows  4 года назад

      40 more to go :) ruclips.net/video/IHrGresKu2w/видео.html

  • @mikeg2798
    @mikeg2798 4 года назад +2

    Another great tutorial. The length and complexity was just right for me. Thanks.

  • @philipjacob1979
    @philipjacob1979 2 года назад

    Thanks Shane. In particular for the remove-item with a * at the end. Helped me delete all subfolders using -recurse -force

  • @andrewsmith5554
    @andrewsmith5554 Год назад +1

    Loving this PS series. Very informative and easy to follow, I appreciate your hard work!

    • @ShanesCows
      @ShanesCows  Год назад

      Glad you enjoy it! Have a good day Andrew.

  • @jennyteul6658
    @jennyteul6658 3 года назад +1

    OMG! this is such a life saver. Thank you so much for this explanation, I'm getting started on my studies in computer science and I was looking for video that I could understand on how to go about using PowerShell and this is yet the best one. I love it. Ill most defiantly be using your videos to come back and understand whatever is being thought at school.

    • @ShanesCows
      @ShanesCows  3 года назад

      Glad to help. 😀

    • @maverickwulf3900
      @maverickwulf3900 3 года назад

      @@ShanesCows also Shane ,you can type GCI instead of get-childitem if you don't want to type the whole thing

  • @BigDawgCleveland
    @BigDawgCleveland 5 лет назад +4

    Remember the old DOS NORTON COMMANDER? I loved that Directory/File management system back in the day!

  • @Dannywwalker
    @Dannywwalker 5 лет назад +1

    Thanks, Shane I've really enjoyed and found useful the series so far.

    • @ShanesCows
      @ShanesCows  5 лет назад

      Cool. 😎

    • @albryant2385
      @albryant2385 4 года назад

      how the hell do i delete powershell in windows 7

  • @robbybaggio4007
    @robbybaggio4007 7 лет назад +55

    Shane, please consider making a video about when to use brackets, double brackets, parenthesis, double parenthesis, comas, semi-colon........it gets confusing for beginners

  • @thunderthreads
    @thunderthreads 3 года назад +1

    Shane Young enjoyed another session, so many questions but first let's start with the kudos, after all I can see that some effort was put into this session for such a good presentation. The fact that you don't bash or assume anything about your audience is super user great stuff. I want to drop a bit for the pipeline, I am an old guy, been around for a minute consumed as much data as I could on my ms pursuit, the start-transcript days for me 286, 386, 486, DOS, 3.1, 4.0 days. You get the picture. Almost like the picture show "Castaway" Tom Hanks, where he was on top of his game with Fed Ex, crash landed, fell out of the cloud for a minute. Well I'm that guy and I am meshing the networking together for a back to the future experience. So, great show you made reference to some of the stuff like DOS to powershell, how much of the old tech scraps are still in viable use? What would be a fast track to fill in the nuggets approach would you take and is it possible to use powershell to communicate to onedrive, If so, how? Do you have a complete series of the Vids?

    • @ShanesCows
      @ShanesCows  3 года назад

      Hey Rick. I hope you have enjoyed the journey. I never did much with PowerShell and OneDrive. Not sure why. I do have 40 general PowerShell videos but nothing specific. 😑

  • @natikrak
    @natikrak 4 года назад +1

    Thank you for the video. You have a great talent to teach! Have a wonderful day!

  • @fluidman777
    @fluidman777 3 года назад +1

    Hey Shane Thank you am a pentester, your videos are priceless!! i can now navigate through windows systems. am from unix based terminals.

  • @joelh577
    @joelh577 4 года назад +1

    clear knowledge and useful ! I love you, awesome guy, fantastic video!

  • @OnixEdge
    @OnixEdge 2 года назад +1

    this is just wonderful! thank you very much, Shane!!! just what I was looking for.

  • @deepaligupta733
    @deepaligupta733 6 лет назад +1

    nice video Shane

  • @maverick86able
    @maverick86able 4 года назад +1

    hi Shane, thank you for sharing your knowledge with all of us. most appreciated, and i hope and wish you folks are doing good.
    i request you to share a tutorial about information on working with remote computers when trying to copy a folder from a local machine to multiple target servers. i am a bit confused about how to pass on the remote directory variable.

    • @ShanesCows
      @ShanesCows  4 года назад

      Sorry I haven’t done much with remote computera

    • @maverick86able
      @maverick86able 4 года назад

      Shane Young , thank you for reverting, I finally managed to create correct variable and now have a script to copy a folder to multiple computers

  • @MichaelFenley
    @MichaelFenley 2 года назад

    very, very, very helpful. Thank you.

  • @shockzula2937
    @shockzula2937 2 года назад +1

    This may sound odd, but you sound A LOT like Charlie Kelly from It's Always Sunny in Philadelphia. I love it cause it makes me feel like I'm being taught by an old friend and it's a lot of fun! Anyway, thanks for the great video!

    • @ShanesCows
      @ShanesCows  2 года назад +1

      Love that! A few people have mentioned that along the way. Have a great day!

  • @libofsharaku
    @libofsharaku 5 лет назад +1

    here's a beast of a task for you Shane, i am trying to create a powershell script which connects to a table in a database, the table contains 3 columns, filename, sourcepath and destination path, the powershell script reads these values from the table(stores them in an array perhaps?). It reads the sourcepath (folder location), it goes to the source folder and depending on the filename it determines the destination(folder location) it is moved into, all the while writing to a log table and capturing the errors. There's a lesson video for you. cheers.

    • @ShanesCows
      @ShanesCows  5 лет назад +1

      What have you tried this far?

  • @alessiocicillini7035
    @alessiocicillini7035 3 года назад

    Amazing video ...Thanks a lot Shane
    Could you make a video to automate AutoCAD or any programs with PowerShell?

  • @robertopulido9557
    @robertopulido9557 4 года назад +1

    thank you, you are good teacher

  • @markandeyulur775
    @markandeyulur775 6 лет назад +1

    Hi Shane, thank u for doing this video.It is very helpful for me.

  • @ginnyharvey3225
    @ginnyharvey3225 6 лет назад +1

    Hi Shane, thank you for your videos, they are very clear and easy to follow. I have heard that with PS6.0 it is possible to download web pages using WebRequest. I am interested in experimenting with scraping websites using PS, is it possible that you could do a video on this subject. It would be truly awesome if you could.
    Thank you again.

    • @ShanesCows
      @ShanesCows  6 лет назад +1

      I will see if I can add it to the list.

  • @vinod-ij7dz
    @vinod-ij7dz Год назад +1

    Thank you Sir.

    • @ShanesCows
      @ShanesCows  Год назад

      Happy to help. Have a great day. 🐶

  • @sriniqatestengg5993
    @sriniqatestengg5993 5 лет назад +1

    Hey Shane your videos shares good info, Can you provide the solution or your views on the below -
    Step 1: Delete the folder A from drive D.
    Step 2: Copy the folder B from Drive C to Drive D.
    Step 3: After copying the folder from Drive C to Drive D, compare the size of the folder B in Drive D and folder B in Drive (To ensure the complete file moves or not, size of file will be GB or TB).
    Step 4: Delete the folder B from Drive C.

    • @ShanesCows
      @ShanesCows  5 лет назад

      Yikes. What have you tried?

  • @lahernandezs
    @lahernandezs 7 лет назад +2

    Hey Shane! you´re awesome! maybe you can post in the near future the video you talked about copying/moving SPO files with metadata, please please please, then I will owe you the best cup of coffee, Greetings from Costa Rica!

    • @ShanesCows
      @ShanesCows  7 лет назад +2

      :) I do need to do that video. It is just so ugly. Let me look at my notes and see what I got. Tell you what, email me and I will send you the pieces so at least you can play with them while I think about how to make it an actual video.

    • @lahernandezs
      @lahernandezs 7 лет назад

      that´ll be great! email account sent I´ll be by Florida on Aug 4th so if you give me a shipping email address I´ll be honoring my word about the coffee. just let me know grind or grain. Let´s pray US customs don't confiscate it hahaha

    • @albryant2385
      @albryant2385 4 года назад

      how the hell do i delete powershell in windows 7

  • @samjames7797
    @samjames7797 5 лет назад +1

    Very informative videos.. any video on copying file with permission or working with share and NTFS permissions using powershell?

    • @ShanesCows
      @ShanesCows  5 лет назад

      I don’t. Never had to get into permissions. Sorry.

  • @fabioflorencio8787
    @fabioflorencio8787 2 года назад

    Obrigado!

  • @BeniSAV
    @BeniSAV 5 лет назад +1

    Очень полезноы видео делает автор канала. Спасибо за этот контент! :)
    Нужно больше видео по powershell! :)

    • @ShanesCows
      @ShanesCows  5 лет назад

      Sorry I don’t speak the language

    • @mjackstewart
      @mjackstewart 4 года назад

      He says it’s a very useful video and thanks you for it, it’s a very great video on PowerShell.

  • @ericabdul247
    @ericabdul247 5 лет назад +1

    Hi Shane, great video. Im new to PS and it defn helps. How do i copy folders with spaces

    • @ShanesCows
      @ShanesCows  5 лет назад

      Not sure. Sorry. But try using ‘ around the path.

  • @dg-hughes
    @dg-hughes 5 лет назад +1

    start-transcript alone is very useful especially for new users who may have done something good but forget how they did it

  • @elvispresly2802
    @elvispresly2802 5 лет назад +1

    Quite a useful video. Could you say about get-help at the beginning?

    • @ShanesCows
      @ShanesCows  5 лет назад +1

      My video learn PowerShell covers get-help

  • @apoorvadipankar
    @apoorvadipankar 5 лет назад +1

    Thank you Shane..its really helpful video. I have a quick question i want to put a filter to move oldest folder only and once it move it must have the same name at the destination..

    • @ShanesCows
      @ShanesCows  5 лет назад

      What have you tried?

    • @apoorvadipankar
      @apoorvadipankar 5 лет назад

      I learn about the move item command from the video so far. But not sure how to add the filters.

  • @jyothimadan6558
    @jyothimadan6558 4 года назад

    Can you please share video of different ways of exporting the outputs in excel,word etc.,

  • @Rood67
    @Rood67 7 лет назад +1

    I saw a comment on one of your videos that the person liked your style of explaining things; and I have to agree. I've been using PowerShell for a few years now; however, I still watch a lot of videos so I know who and where to point new people to. That said, I would like to ask that you change your font colors.
    Maybe if you haven't already, do a video on c:\Users\%UserName%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
    And cover things like:
    $Host.UI.RawUI.ForegroundColor="Cyan"
    $Host.UI.RawUI.BackgroundColor="DarkBlue"
    $Host.PrivateData.VerboseForegroundColor = "White"
    $Host.PrivateData.VerboseBackgroundColor = "Blue"
    Because as it is; your text in the videos is extremely hard to read depending on it being my monitor at work vs my monitor at home. So, I'm sure that if I'm having an issue, someone else is having a difficult time reading what you're typing as well, especially quoted text for strings and such.

    • @ShanesCows
      @ShanesCows  7 лет назад +1

      Thanks for the feedback. I do need to cover the profile stuff, and yeah I try to go with larger sizes to account for the colors. The challenge from my point of view is if I change the colors that is one more thing for a newbie to deal with not looking like their screen. That is why I have stayed default thus far. But you are right quoted text is ugly to read. Pros and Cons. Thanks for watching and I will see what I can come up with.

    • @Rood67
      @Rood67 3 года назад +1

      @@ernest73 anything on RUclips by Don Jones, CBT Nuggets, or one of the nearly six hour videos from Microsoft with Jerry Snover.

    • @ernest73
      @ernest73 3 года назад +1

      @@Rood67 John Hammond is pretty good with early basic stuff also I found him last night

  • @mayatrac4307
    @mayatrac4307 4 года назад +2

    Thanks for the video Shane! I tried to do the copy-item with -recurse, but it doesn't work. The newer file copied over the old file. Any suggestions?

  • @IshaanKhistiDiving
    @IshaanKhistiDiving 5 лет назад +1

    Hi Shane, great video and tips. I am a total novice and have been given a task to copy files from a non-internet environment through the firewall on to the business domain. I have a firewall rule in place to go through any ideas?

    • @ShanesCows
      @ShanesCows  5 лет назад

      Can you map a drive to the Internet spot?

  • @kimran8830
    @kimran8830 7 лет назад +1

    Please add topic on creation pf Array,Hash,Functions And on Registry.

    • @ShanesCows
      @ShanesCows  7 лет назад +1

      Sound like great ideas. I will add them to my list. Thank you.

    • @kimran8830
      @kimran8830 7 лет назад

      Shane Young Thanks for considering my opinion . I didn't understand clearly on | Get-Member on objects & property if their is any blog created by you let me know

  • @christopherromo8013
    @christopherromo8013 6 лет назад +2

    im not a sys admin...
    but you have gained my sub!

    • @ShanesCows
      @ShanesCows  6 лет назад

      Thanks. Hope I can live up to the pressure of keeping you around. :)

    • @christopherromo8013
      @christopherromo8013 6 лет назад +1

      Shane Young luckly im actually not a very picky person xD just really ethusiastic about pcs

  • @zoltar14102008
    @zoltar14102008 6 лет назад +1

    Shane great videos , any chance of videos of working with excel files workbooks etc instead csv files. And can PS create graphs from objects

    • @ShanesCows
      @ShanesCows  6 лет назад

      I have never done Excel. I hear it is a pain in the butt. 😎

    • @zoltar14102008
      @zoltar14102008 6 лет назад +1

      Shane Young thanks hence the need for help. ... how about creating your own modules..

    • @ShanesCows
      @ShanesCows  6 лет назад

      I built one module but never did a video on it. It is on the list but deep. Sorry. I am no help

  • @dravarni7264
    @dravarni7264 5 лет назад +1

    Nice Job...I'm using a version of PS inside Atom...

  • @Hypocycloid3
    @Hypocycloid3 5 лет назад +1

    Like the vids. Can you do a Powershell one as it pertains to SCCM?

    • @ShanesCows
      @ShanesCows  5 лет назад

      That would be great but I have not used sccm in years. Sorry

  • @tobietravis5142
    @tobietravis5142 6 лет назад +1

    Shane, do you have a PowerShell script handy that shows how to MOVE a FOLDER and all of its contents from ONE Library to a DIFFERENT Library in a SharePoint Online site when the value of a field changes ?

    • @ShanesCows
      @ShanesCows  6 лет назад

      Check out this video. Should at least get you moving in the right direction. ruclips.net/video/xwKTFfhQWLY/видео.html

  • @paulvoorham1784
    @paulvoorham1784 7 лет назад

    Hi Shane, this was again a great video especially for someone that is learning powershell, is it possible to create a video on how to get a download link from a file that is stored on your onedrive folder and sent this link by mail to your client?
    that would really awesome if you could do this.
    thanks in advance.

    • @ShanesCows
      @ShanesCows  7 лет назад

      Thanks Paul. In theory all of the pieces are there but I haven't tried to do exactly what you are asking. I would look at the properties of the file and see if you get the URL you need, I am sure you do, and then you can use Send-MailMessage to email from PowerShell. Please share if you get it all working. Thanks again - Shane

    • @paulvoorham1784
      @paulvoorham1784 7 лет назад

      Shane Young hi Shane, the problem is that I'm a novice on powershell and I try to figure out how to get it done. I know Vba but powershell is new to me. I read that it should be possible to do this by adding the onedrive api to powershell. But further then this I didn't get. So I saw your videos and was wondering if you could help me out. Thanks for taking the time to read this post

  • @passionforprotest
    @passionforprotest 4 года назад +1

    Great vid but I got a question:
    Is there a way to open a file straight from powershell?
    For example, you listed doc1, doc2, excel etc.
    Is there a command where you can open doc1 without needed to move the mouse over to file explorer?
    Thanks

    • @ShanesCows
      @ShanesCows  4 года назад

      I thought so but I haven’t done it in a while but I think if you just pass the file name it will treat the file with the default behavior for that file type. But now I am not sure. 😑

  • @8bitwidgets
    @8bitwidgets 5 лет назад +1

    This was great and right on with what i need to know, but i have a question. i want to write a script that would copy off of a network drive. I can do things like "cd N:" and it will go to that drive which is great, but the folder i want to reach is not a drive that is mapped to the users.. so when i look at the address it reads like this..
    \\server\Shared\Private\Database\
    when i do something like "cd \\server\Shared\Private\Database" it doesn't know what the location is. Some answer to this?
    I think what you're showing me is 90% of what i need to know.. basically i just want to make a script that would grab a file in a network folder and paste them on the individuals desktop when they run the script.
    It's an access database used by many and they can't (shouldn't) run the original copy on the drive.. so we have them manually copy over a db file locally to make changes without people stepping on each others toes. However we often make fixes / updates to it so I was thinking of making the manual process automatic..

    • @ShanesCows
      @ShanesCows  5 лет назад +2

      There is a way to connect network drives in PowerShell. I forget at the moment but if you search it is possible and then this would be easier b

  • @adeinkheart3111
    @adeinkheart3111 6 лет назад

    wonderful tuts dude... however I had a slight challenge, when I created a folder, I couldn't reference it in powershell just like you did with the demo stuff

    • @ShanesCows
      @ShanesCows  6 лет назад

      What happened? What error message did you get?

  • @TheStevenWhiting
    @TheStevenWhiting 5 лет назад

    Any ideas on removing files with specific characters in the file name? Have old photos that are named odd123.jpg and odd123 (2).jpg. Both the same image so I want to remove the (2).jpg files but not the original.

    • @TheStevenWhiting
      @TheStevenWhiting 5 лет назад

      Worked out what I wanted
      get-childitem | Where-Object name -Like '*`(2)*' | ForEach-Object { remove-item -LiteralPath $_.name }

  • @hphan276
    @hphan276 6 лет назад

    Hi Shane. I was using get item and get childitem on my desktop. What I dont understand is there are clearly file in there however it wont be shown. Is there a particular reason for that.

  • @snailsnail7360
    @snailsnail7360 6 лет назад +1

    When opening powershell, it took forever. I had started typing and not seen any input registering until 3 minutes later. Is there anything that might cause this?

    • @ShanesCows
      @ShanesCows  6 лет назад

      Haven’t seen that before. What version of PowerShell do you have? Old pc?

  • @cblack2863
    @cblack2863 4 года назад +1

    How do you work with Files based on attributes such as tags, rating and dates?

    • @ShanesCows
      @ShanesCows  4 года назад

      If they are properties you can use them to filter and such.

  • @stormwall1642
    @stormwall1642 5 лет назад +1

    Hi Shane I'm having trouble finding the folder to access. What files will work with this. Can I move stuff from my documents folder to my desktop. I can't get it to pull up a y of the folders I try. Thanks for your help. Keep up the videos is slow learning for me but I'm trying to learn shell thanks

    • @ShanesCows
      @ShanesCows  5 лет назад

      Ben yes, you can. What path are you trying? C:\users\shane\desktop?

    • @stormwall1642
      @stormwall1642 5 лет назад +1

      @@ShanesCows I did it the same way u did in the video using my documents and a another folder on my desktop . But neither one would work.

    • @ShanesCows
      @ShanesCows  5 лет назад

      Maybe the files aren’t really on the desktop. Try a simple folder first like c:\ demo and see if you can get that to work.

    • @stormwall1642
      @stormwall1642 5 лет назад

      @@ShanesCows I have a folder on desktop but I'm not sure. I will keep trying. I will try it with another file thank you .

  • @MrSuhas888
    @MrSuhas888 5 лет назад +1

    I have files on different servers, I would like to make a directory with a dynamic name and then copy all the files generated latest date on different server to the newly created dynamic folder, How can I do that with PS script

    • @ShanesCows
      @ShanesCows  5 лет назад

      The pieces are here. Maybe look for the video on string manipulation for some more help.

  • @xhyhbdka
    @xhyhbdka 4 года назад +1

    Hey Shane, how would you find out the number of pages from those documents? Without having to open them?

  • @Sachin-qj6dd
    @Sachin-qj6dd 5 лет назад +1

    Shane, Is there a way to open a file in an application with PowerShell, Calling an .exe file and going to taskbar FIle and click on Open.

    • @ShanesCows
      @ShanesCows  5 лет назад

      Yes. Been a while but I know it is possible. What app do you want to open? I think this blog post shows it. www.energizedtech.com/2010/03/quickly-open-files-with-defaul.html

  • @vinayraju2632
    @vinayraju2632 4 года назад +1

    @shane how did u paste the path of demo 2 folder? and how did u get the path by CLICK in the command line at video duration from 7:40 to 7:46

    • @ShanesCows
      @ShanesCows  4 года назад

      Turn on Quick Edit in PowerShell

  • @satishagrahari557
    @satishagrahari557 5 лет назад +1

    Thanks it help me lot to learn this but i have a problem in coping folder when I have copy a folder one location to another location there was a error file path is too long I have tried so many solution but it helpless. Is there is any power-shell command to avoid file path is too long error.. Plz help.?

    • @ShanesCows
      @ShanesCows  5 лет назад

      I haven’t ran into that before but I am going to guess you are going to have to find a way to shorten the path. 😑

  • @limacal
    @limacal 6 лет назад +2

    Great explanation on Copying, Moving and Deleting Files!!!
    How do I write in PowerShell before copying the files over, to check if the files already exist in the folder "DONT COPY THEM"?
    How do I use "IF Statement" with that? I would like to check the destination folder first if it has the files already instead overwriting them. Any Thoughts?
    Thank you very much for the great videos!!!

    • @ShanesCows
      @ShanesCows  6 лет назад

      Use Get-ChildItem YourNewFile.docx to try to get the file before you write it. If Get-Childitem is blank then you know it is safe to write the file. If Get-ChildItem returns a file then you know you want to show your error and not write the file.

    • @limacal
      @limacal 6 лет назад +1

      Thank you

  • @EdResleff
    @EdResleff 5 лет назад +1

    Hi Shane... I have a rabbit-trail question about copy-item (sort of). I am on a central server... I have a New-PSSsession to a remote machine... I have a PowerShell script that I want to run against said remote machine, so I am doing a Copy-Item of the script to the Session... then I am doing an Invoke-Command to run the script. Then, I was the output from the script to be copied to the central server. If I am creating a persistent PSSession and doing an Invoke-Command, isn't the Invoke-Command already doing the Copy-Item? And, am I really copying the PSscript to the remote machine or am I running the command in the persistent PSSession?
    Great video series btw...!

    • @ShanesCows
      @ShanesCows  5 лет назад

      Hey Ed. I haven’t done anything with remote sessions so I am no help here. Sorry.

  • @markouellette788
    @markouellette788 4 года назад +1

    Are you able to delete all of a certain file extension based on the creation date and older? So all files with .docx 3months or older delete in all subdirectories.

    • @ShanesCows
      @ShanesCows  4 года назад

      Yes. You would need to write a filter that returns the items you want and then pass those objects to the delete.

  • @mikewabrown1052
    @mikewabrown1052 2 года назад +1

    nice vid

  • @deankreiler7897
    @deankreiler7897 6 лет назад

    How do you rename, delete part of title on multiple files i.e. Videos at the same time

    • @ShanesCows
      @ShanesCows  6 лет назад

      Do you mean like using Rename-Item? Maybe mix that with my video on string manipulation? Give me an example and if I can give you a quick answer happy to share.

  • @JLeeHughesKCHWA
    @JLeeHughesKCHWA 3 года назад +1

    so if you are redoing cmd scripts
    to powershell
    is there a translation table
    I have bash unix alread

  • @fassifern
    @fassifern 6 лет назад

    Great video. Do you have any example on how to rename and organize non persistent file names with spaces in random place in a file name? For traditional dos I used "for" to delimit to separate then give each common string to put aside and rid off strings between then organize the file name more legibly. E.g. file names. "file 123 34_7.xlsx" "file 3 rt 34_8.xlsx" to file7.xlsx & file8.xlsx - for this I would use something like: for /f "tokens=1,2*" %f in ('dir/b') do @for /f "delims=_" %j in ('echo %g %h') do @ren "%f %g %h" "%f%j" - this I don't want to use

  • @hphan276
    @hphan276 6 лет назад +1

    if I create a random number and make it in an array$random = @(get-random -Minimum 0 -Maximum 50) like this how can I check how big the array is if the number come out like 1 character or like 23

    • @ShanesCows
      @ShanesCows  6 лет назад

      I am sorry, I don't follow your question. :( If i run:
      $random = @(get-random -Minimum 0 -Maximum 50)
      I just get one number stored in the $random variable.

  • @brendablack1587
    @brendablack1587 6 лет назад

    How to access and edit files on a remote computer using powershell. OR, get a file from a remote computer so that I can edit and then put it back

    • @ShanesCows
      @ShanesCows  6 лет назад

      If you are a local administration you get to those remove files directly, without any magic, by using \\computername\c$\folder the adminstrator share is a great way to get those one of things. Does that help?

  • @walterdoku3020
    @walterdoku3020 6 лет назад +1

    How do I delete files older than a certain number of days??

    • @ShanesCows
      @ShanesCows  6 лет назад

      You would just need to work on your Get-ChildItem to only return the old items. This blog post should help. blogs.technet.microsoft.com/heyscriptingguy/2014/02/07/use-powershell-to-find-files-that-have-not-been-accessed/

  • @vivekchandra9622
    @vivekchandra9622 5 лет назад +1

    Hi Shane can powershell be used to send or copy from one server to another server like for ftp ..

    • @ShanesCows
      @ShanesCows  5 лет назад

      It can but I don't have any examples.

  • @midnightwatchman1
    @midnightwatchman1 5 лет назад +1

    I was recursively going through file directories a file server to delete particular files but keep get an error about directory path too long. is there a limit on how long a path can be in PowerShell this seem strange

  • @hphan276
    @hphan276 6 лет назад +1

    I am trying to open stuff on my this pc desktop. why cant I set location to this pc desktop.

    • @ShanesCows
      @ShanesCows  6 лет назад

      What folder are you navigating to? For me it is CD C:\Users\Shane\Desktop

    • @hphan276
      @hphan276 6 лет назад

      I figure it out actually. I have a couple more questions regarding powershell. I dont know if it is ok to email you.

  • @johnmcgiv1
    @johnmcgiv1 4 года назад +1

    Sorry Shane hit wrong position on keyboard and sent previous message unfinished. Is it possible to write a script to start 'Start Transcript' automatically? Thanks for your patience.

    • @ShanesCows
      @ShanesCows  4 года назад

      John this video. Put it I. Your profile ruclips.net/video/jQzgSxetr5I/видео.html

  • @sheepusdobeanimating
    @sheepusdobeanimating 3 года назад +1

    Hey shane I need some quick help-reply here about PowerShell I just need to know how to change the powershell location

  • @johnmcgiv1
    @johnmcgiv1 4 года назад +1

    Hi Shane, this may seem a dumb question as I am an old complete newbie virtually know zilch but I was wandering can you not wtit

    • @ShanesCows
      @ShanesCows  4 года назад

      Replied to the other comment

  • @ricklarrea
    @ricklarrea 6 лет назад +1

    Shane, How would I delete all files larger than 50MB?

    • @ShanesCows
      @ShanesCows  6 лет назад

      Set the filter on get-childitems to filter for items greater than 50 mb then pass that to remove.

  • @lukass.3124
    @lukass.3124 3 месяца назад +1

    if i use get-childitem - recurse and remove-item to remove files and folders I get the path to long exception.
    Do you know of any easy way to handle that? (Forcing the command did not end up deleting the files/folders)

    • @ShanesCows
      @ShanesCows  3 месяца назад

      Sorry, it has been a long time since I have played with that stuff, I am no help. :(

  • @dreamcatchers234
    @dreamcatchers234 Год назад

    how to move selected folders from one folder to another folder

  • @PraveenTata16
    @PraveenTata16 6 лет назад

    foreach($folder in $folders) {cd $folder.FullName; Remove-Item *.txt;}
    Is this the correct way of iterating through all sub folders and deleting text files inside those sub folders?
    It works, but just wanted to know the right approach.
    Thanks.

    • @ShanesCows
      @ShanesCows  6 лет назад

      get-childitem -Include *.txt -Recurse | Remove-Item
      That is what I came up with quickly. You should test it and there still might be better ways but that should work.

    • @PraveenTata16
      @PraveenTata16 6 лет назад

      Shane Young great! I will try that out.

    • @PraveenTata16
      @PraveenTata16 6 лет назад

      Thanks. I will try this out.

  • @franciscoalfonso
    @franciscoalfonso 4 месяца назад +1

    Hi Shane. I have drive E(1TB) and drive F(8TB). Need to write an script to do this : read E and look if the file is already at F. If yes, write a .txt file in drive C with the folder\filename in E and the folder\filename in F. If not in F, copy file from E to F keeping same directory structure and write to above .txt folder\filename in E and the folder\filename in F. Continue till all drive E has been explored. My problem is that some years ago I copy many files from E to F but I distributed those in different folders at drive F, so I can not use an standard backup tool because they are designed to look for same structure in both source and destination drives. Do you have an script to do what I want?

    • @ShanesCows
      @ShanesCows  4 месяца назад

      Sorry, I haven't done anything close to that in years.

  • @johnmandrake8829
    @johnmandrake8829 3 года назад +1

    how to troubleshoot in powershell?

  • @stephaneb4630
    @stephaneb4630 6 лет назад

    How do you remove a link from a text file like notepad.exe? The link would start from: www. and end with the end domain extension like .com, .net...etc. Thanks I like you videos!

    • @ShanesCows
      @ShanesCows  6 лет назад

      I don’t have the answer handy and I am on my phone not my computer to help you look. It is possible. Let me know if you can’t find it.

    • @stephaneb4630
      @stephaneb4630 6 лет назад

      I found something like extract a link from a web site, but now I need to take out some before the links.. I used
      get-content, and
      $Content | % { if($_ -match ": http") {write-host $_}}
      to get links. Now I must remove the following:
      "href : "
      from href : websiteurl.com/, any ideas? ;-)

  • @AshishSharma-gq5oj
    @AshishSharma-gq5oj 3 года назад +1

    Hi shane, i want to copy files one server to another server using power shell script it is working, but when we scheduling task in task scheduler nothing is happen showing message task completed but i am unable to found any file on another server. Copy-Item "C:\xyz.html" -Destination "\\DC01\g$\Snapshot",here is this command...plz check & confirm...why this script not working in task scheduler or help me something else...

  • @causap
    @causap 5 лет назад +1

    How do you get the path " \\DESKTOP-3Q38SP3\demo2" ? Where do you get it?

    • @pinkmillk
      @pinkmillk 5 лет назад +1

      it's a shared folder, thus "\\DESKTOP-3Q38SP3\" is the root location on the network. demo2 was a folder inside of that location.

    • @pinkmillk
      @pinkmillk 5 лет назад +2

      Either that, or I'm just as confused as you are.

    • @causap
      @causap 5 лет назад +1

      @@pinkmillk Sorry, how do I find it? I'm totally new in this. 100% Newbie.

    • @pinkmillk
      @pinkmillk 5 лет назад +2

      @@causap Easiest way is to right click the directory you're looking for, click properties, go to the sharing tab. The network path is what he's using.

    • @pinkmillk
      @pinkmillk 5 лет назад +2

      I found this by creating a new folder on my desktop and doing the same. Because I was checking a local directory instead of a network folder, it just shows up as the path we're used to seeing except with
      "\\[computer name\[path]"
      instead of "c:\[path]"

  • @prem.sagar.m
    @prem.sagar.m 4 года назад +1

    After copying a file using powershell it is being locked by poweeshell any solution

    • @ShanesCows
      @ShanesCows  4 года назад

      Not sure. I haven’t ran into that before.

  • @BADRUBULDURA
    @BADRUBULDURA 3 года назад +1

    🙂

  • @ariesapolloadventures1512
    @ariesapolloadventures1512 6 лет назад

    This in no way helped me delete a wav file from my computer. 8 hours straight trying to figure this out.

    • @ShanesCows
      @ShanesCows  6 лет назад

      Why are you struggling to delete a file? What did your code look like?

    • @ariesapolloadventures1512
      @ariesapolloadventures1512 6 лет назад

      It's like a ghost file. It was broken when I downloaded it. When I go to delete it is says "discovering" but never finds it to delete it. The name of it is very long and it will not allow itself to be renamed or moved.
      It is on my PC \ downloads \ Ferrari Offset ect
      The file name has spaces so I dont know if this affects it.
      But it could not locate the file based on your instructions.

  • @chakrabmonoj
    @chakrabmonoj 3 года назад +1

    Hey Shane - lovely videos as I am starting to have fun with PS. I am currently struggling with two problem and it would be great if you help me with the codes :
    1. I want to set a encrypt a folder (and the files within) with a password for data protection
    2. I want to change the file-creation and modify dates for a particular file - for this when I am giving the path, PS is returning an error "position parameter"....not able to work around that. Is there a specific way to provide the path, if it is something like c:\users
    ila9\downloads\academic books\coding\xxxx.pdf [the position is error is occurring at the "academic books" part. Is that because of the space in the name of the folder?
    Thanks a lot

    • @ShanesCows
      @ShanesCows  3 года назад

      I am not sure Monoj. Sorry

    • @Bytrl
      @Bytrl 2 года назад

      I'm completely new to ps, and your comment is a yr old, but maybe you're encrypting the files prior to manipulation further down the script? In your scenario, I'd try restructuring the order of events. Create the directory, move the files in, then reorganize as necessary, then encrypt/decrypt using a try catch with read-host -name (password) so if the password entered is correct, the path is decrypted, else an error is logged, and the script is thrown. 🤷🏻‍♂️

  • @kirkin2006
    @kirkin2006 7 лет назад +1

    Back to DOS... Console rules now. Microsoft money-maker machine.

  • @albryant2385
    @albryant2385 4 года назад +1

    how the hell do i delete powershell in windows 7

  • @marcolucas8192
    @marcolucas8192 4 года назад +2

    I come from linux, is funny to see powershell in use in windows machines world: much more confusing, much more caotic, and much less eficient and fast than linux terminal shell. I mean is like 1000-10 score... winning Linux of course...

    • @ShanesCows
      @ShanesCows  4 года назад +1

      I remember when terminals were actually terminals 😂

  • @troybryantIII
    @troybryantIII 6 лет назад +2

    intro makes me think of strip club...otherwise great stuff

    • @ShanesCows
      @ShanesCows  6 лет назад

      Thanks. I will leave all of my snarky responses out to avoid getting myself in trouble. :)

  • @uynguyen7431
    @uynguyen7431 Год назад

    You funny

  • @sbgaming6951
    @sbgaming6951 3 года назад +1

    its so frustrating when you watch a tutorial and they forget to mention something so simple as how to navigate to a folder that has spaces in its title. I stopped watching when he just blew past one of the most essential things to know.

    • @ShanesCows
      @ShanesCows  3 года назад +1

      Sorry you didn’t like the video. I have over 40 PowerShell videos and I can’t cover everything in every video. 😐

    • @sbgaming6951
      @sbgaming6951 3 года назад +2

      @@ShanesCows then you should've said I won't be covering that in this video. I can't copy, move or delete a file if I don't know how to access it. All you literally had to say is put an apostrophe before the space if it has spaces. Plus learn to take criticism it makes you better

  • @celloorozco9730
    @celloorozco9730 3 года назад +1

    dog just tell show how to move files from one directory to another... split all this shit up...

    • @ShanesCows
      @ShanesCows  3 года назад

      Sorry, easier for me to group the videos like this.

  • @horstgrundkenfelder4558
    @horstgrundkenfelder4558 4 года назад

    Get rid of the talking head window. It's distracting and adds nothing useful to the tutorial.

    • @ShanesCows
      @ShanesCows  4 года назад

      Sorry you don't like it. Most viewers do enjoy my ugly face though.