Looping through subfolders with [foreach]
What I have now: ## Create variables for subfolders $sub = @("Lectures", "Labs", "Assignments", "Scripts") ## Loop through collection to create subfolders foreach ($item in $sub) {New-Item -ItemType...
View ArticleAppactivate not working on Windows 10
Hello all. I have a script that runs perfectly fine in a Windows 7 enviornment, but when I try to run it in Windows 10, it fails every time. The AppActivate portion fails consistently. I tried...
View ArticleManaging Security Settings on Nano Server with DSC
submitted by /u/PowerShellChallenge [link] [comments] The post Managing Security Settings on Nano Server with DSC appeared first on How to Code .NET.
View ArticleHelp with string to date conversion
I’m working on a simple script to read a log file, convert the latest reboot item flagged in said log file and convert it to a date object so I can compare it to another date object. I’ve spent hours...
View ArticleLooking for help to modify
I need to modify this script, https://gallery.technet.microsoft.com/scriptcenter/Get-remote-machine-members-bc5faa57 To pull data from 2003 servers and 2008 servers on a domain. I need to pull against...
View ArticleMove-item error after copying
Here’s the bit of relevant code, and the error: http://imgur.com/a/LEtb2 ## Get a listing of the files in the Copy folder and move them to the appropriate subfolder $copyListing = Get-ChildItem...
View ArticleHow can I have PowerShell compare text between files and copy lines from one...
I’m trying to come up with a solution to help automate the deployment of some of our applications. They are all .NET applications with web.confg files and each file has a customer specific connection...
View ArticleDo/while jobs still running.
Plan is to query the jobs for 10 minutes or until they have all completed, but it still always goes on for the 10 minutes. I want to output the results also during the do/while time. What am I...
View ArticleWhat is an “efficient” script?
Is it one with least lines? Is it one with Maximum used aliases to reduce the total number of characters? What should be preferred? Readability (using Get-content, Set-Location) or Lowest character...
View ArticleError messages being tossed out, is it the logic in the code?
Hello all, Ive pasted the relevant bit of code below. For some reason, Im getting these errors, saying it cant move the items because they dont exist. This confuses me, because how could they not...
View ArticleHow to put output of command into existing text file without overwriting its...
I used: Get-Service | Out-File c:scriptsoutput.txt but now I need to output this: Get-Process | Out-File c:scriptsoutput.txt to the same text-file without overwriting its existing contents. How?...
View ArticleRemove background job if script stopped in ISE
I’m starting some background jobs on the local computer and wanting to terminate the background jobs if the script execution is stopped in PowerShell ISE. Here’s some sample code with comments for the...
View ArticleCalling a powershell script from another and passing parameter argurment..help
Hi guys , I have two scripts that reside on same machine (stuff.ps1 , stuffwrapper.ps1). I need for stuffwrapper.ps1 to call stuff.ps1. Stuff.ps1 is run with a -path parameter .stuff.ps1 -path...
View ArticleSearch/ack using the Windows Search index from powershell
submitted by /u/gfody [link] [comments] The post Search/ack using the Windows Search index from powershell appeared first on How to Code .NET.
View ArticleConfirm Get-Credential
This seems to work, but the loop continues and asks me for credentials again and again and recreates them again if it successful. I want to re-ask for credential if the schedule fails, but only the...
View ArticleTerminating a Remote Session (ISE)
Sometimes when I am running a block of code on a remote machine via invoke-command or in a PSSession, sometimes the code will hang and not terminate. Whether I hit the stop button at the top, or...
View Article[X-Post /r/exchangeserver] Administering Exchange 2010 and AD from Windows 10...
Hello, I’m currently in the process of setting up my new workstation based on Windows 10 and, coming from Windows 7, I’ve hit a snag many others may have. Over the years, I’ve built quite a few...
View ArticlePoSH Script for disabling / re-enabling services
Hi guys, I have a monitoring agent across a load of servers, I would like confirm monitoring is working on a regular basis. I can do this manually by disabling the service for 10 mins or so. Has...
View ArticleAdd paravirtual SCSI controller to running machine
This has come up several times for me, and I got frustrated that I can create a SCSI controller via the GUI and then add a drive to it without turning a machine off, but Add-SCSIController does...
View ArticleHow do I get credit for my scripting while sharing my scripts?
Editing a .ps1 is simple as editing a .txt And it isn’t advisable to to run a .ps1 from a unknown publisher. So, is there anyway to protect my code and/or get credit for my work without being asked...
View Article