Question on Functions
I have created a function called Uninstall-Software. I created 2 param at the topfunctionUninstall-Software{param ( [string]$ComputerName='', [string]$Remove="" )This is followed by code. From the...
View ArticleManage Folders Using A Date
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...
View ArticleSearching by file Type
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...
View ArticleUninstall Script - spaces in cmd-line arguement?
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...
View ArticleRobocopy
Hi I am trying to write powershell script for robocopy .Requirement as below example Source(Server1) Destination ( Server2) c:\backup\1 d:\backupc:\backup\2...
View ArticleHas anyone found a Windows Explorer workalike PowerShell script for Server Core?
We are currently testing Windows Server 2012 R2 Server Core, which does not have a GUI, as such. The server just boots into cmd.exe (i.e., NT-DOS) and has a much smaller attack surface (and less...
View ArticleDelete Line Containing Specific Word and Next 2 Lines
I am attempting to write a powershell script that will delete the line containing the <PROCEDURE> in multiple text files and delete the next 2 lines after <PROCEDURE>. No matter what I try,...
View Articlepowershell v5 using where-object
PS C:\> Get-Service | where status -eq "Running"Status Name DisplayName------ ---- -----------Running AdobeARMservice Adobe Acrobat Update ServiceRunning Appinfo...
View Articlefinding multiple instances of filename
Goal: I need to run a command line to uninstall a program on some of our work computers. The command line includes the path to an executable and then some parameters.Possible scenarios: The executable...
View Articleshortcut creation not working
I thought this may be due to our McAfee virus scans but even after I uninstalled McAfee from a Windows 7 machines I still can't create shortcuts with PowerShell. I have this code. Yes, _Productivity...
View ArticleExport-Csv has different results compared to Out-Gridview
I have this code which works (mostly written by Bob McCoy )$pc=Get-Content C:\temp\IE11Fail.txt$results= @()$results=foreach ($machinein$pc) {$computerName= (Get-WMIObject-class Win32_ComputerSystem...
View Articleremote session and displaying output ??
I have discovered that you can't use Out-Gridview within a remote session nor can you write to a file share. I have the code below, the Out-File gets an access denied. But if I try the same command...
View Articletracking null-valued expression
I run my code that gathers certain parameters against multiple machines to create a report. I gather the parameters in a hashtable. Problem is when running the script against one of the machines which...
View Articlefsrmquota workaround help
I'm trying to set a new quota (or re-set existing) and the set-fsrmquota doesn't appear to support the -action param like set-fsrmquotatemplate. All my quotas are custom and do not use a template. My...
View Articleinvoke-command
I have this code:$pc=Read-Host"Enter machine name"$software=Read-Host"Enter software to search for"$softwareInvoke-Command-ComputerName$pc-ScriptBlock {Get-ChildItem-Path...
View ArticleLinux' tac in Powershell?
Is there a way to read huge csv-data-files in reverse orders without loading them at once into the memory - too big?I have huge ASCII csv-data files with the oldest time stamp at the beginning but...
View ArticleUsing Powershell to see if a computer is Windows 7, 8, or 10
Hi All, I'm writing a logon script to install RSAT on a handful of machines. One thing though that has been challenging is having PowerShell check if a computer is Windows 7, 8, or 10. I don't really...
View Articletac in Powershell: read a file line by line in reverse order, last line first...
Hi is there an elegant way to read huge csv-data-files in reverse orders?Each line contains in ASCII "date,time,msec,priceAsk,priceBid,vol" with the oldest date at the beginning. Is there a way to read...
View ArticleMultiple where
Hi all trying to put together a script, I took the follwoing from Virtu Al and this works but for one set of variables, For the life of me I cant get this to work if I add an if or elseif statement...
View ArticleWhere clause not excluding results?
Good Morning All,I am attempting to write a script that targets virtual machines that do not have a VMXNET3 network adapter and are not part of a specified list of names but for some reason my line of...
View Article