powershell

PowerShell - Remove all lines of text file until a certain string is found

北城以北 提交于 2021-02-07 08:50:37
问题 I currently have an output log file that's a bit of a mess and grows quickly. It's the debug output for a large script that permissions mailboxes. I basically just want to delete every line in the file until it finds the first iteration of the date 7days ago. So far, I can return all lines containing that date $content = Get-Content $file $lastweek = "{0:M/d/yyyy}" -f (get-date).AddDays(-7) $content | Where-Object { $_.Contains("$lastweek") } But I can not figure out a function to just wipe

PowerShell - Remove all lines of text file until a certain string is found

坚强是说给别人听的谎言 提交于 2021-02-07 08:46:18
问题 I currently have an output log file that's a bit of a mess and grows quickly. It's the debug output for a large script that permissions mailboxes. I basically just want to delete every line in the file until it finds the first iteration of the date 7days ago. So far, I can return all lines containing that date $content = Get-Content $file $lastweek = "{0:M/d/yyyy}" -f (get-date).AddDays(-7) $content | Where-Object { $_.Contains("$lastweek") } But I can not figure out a function to just wipe

PowerShell - Remove all lines of text file until a certain string is found

China☆狼群 提交于 2021-02-07 08:45:18
问题 I currently have an output log file that's a bit of a mess and grows quickly. It's the debug output for a large script that permissions mailboxes. I basically just want to delete every line in the file until it finds the first iteration of the date 7days ago. So far, I can return all lines containing that date $content = Get-Content $file $lastweek = "{0:M/d/yyyy}" -f (get-date).AddDays(-7) $content | Where-Object { $_.Contains("$lastweek") } But I can not figure out a function to just wipe

Get-ADUser Filter on WhenCreated works for -lt but not -gt

﹥>﹥吖頭↗ 提交于 2021-02-07 08:21:25
问题 I am trying to search for users created after a specified date, but it always returns no results. If I change the -gt/ge to -lt/le it pulls results correctly, so this should be doable. I know I can just filter for all and then do a Where-Object to filter for gt/ge but I really need the filter to happen server side. Any ideas on how to make this successful without doing Where-Object or using the Get-QADUser? Update 2015.01.23: Not always getting this error, but it help point to the issue: Get

Get-ADUser Filter on WhenCreated works for -lt but not -gt

断了今生、忘了曾经 提交于 2021-02-07 08:20:04
问题 I am trying to search for users created after a specified date, but it always returns no results. If I change the -gt/ge to -lt/le it pulls results correctly, so this should be doable. I know I can just filter for all and then do a Where-Object to filter for gt/ge but I really need the filter to happen server side. Any ideas on how to make this successful without doing Where-Object or using the Get-QADUser? Update 2015.01.23: Not always getting this error, but it help point to the issue: Get

Powershell fastest directory list

梦想与她 提交于 2021-02-07 08:17:33
问题 Anyone know a fast way to do a recursive directory listing? I am trying to go through a SAN of about 10tb and "get-childitem -include" takes days to run... I know there will be no way to bring it down to minutes but perhaps some way to cut the time to a few hours would be great. I only need a list i can sort through don't need the file properties as I will be using this to find certain types of files on our SAN such as PST files. If anyone could point me in the direction on how to use the

Powershell fastest directory list

僤鯓⒐⒋嵵緔 提交于 2021-02-07 08:14:24
问题 Anyone know a fast way to do a recursive directory listing? I am trying to go through a SAN of about 10tb and "get-childitem -include" takes days to run... I know there will be no way to bring it down to minutes but perhaps some way to cut the time to a few hours would be great. I only need a list i can sort through don't need the file properties as I will be using this to find certain types of files on our SAN such as PST files. If anyone could point me in the direction on how to use the

Powershell fastest directory list

橙三吉。 提交于 2021-02-07 08:13:03
问题 Anyone know a fast way to do a recursive directory listing? I am trying to go through a SAN of about 10tb and "get-childitem -include" takes days to run... I know there will be no way to bring it down to minutes but perhaps some way to cut the time to a few hours would be great. I only need a list i can sort through don't need the file properties as I will be using this to find certain types of files on our SAN such as PST files. If anyone could point me in the direction on how to use the

Powershell fastest directory list

◇◆丶佛笑我妖孽 提交于 2021-02-07 08:13:02
问题 Anyone know a fast way to do a recursive directory listing? I am trying to go through a SAN of about 10tb and "get-childitem -include" takes days to run... I know there will be no way to bring it down to minutes but perhaps some way to cut the time to a few hours would be great. I only need a list i can sort through don't need the file properties as I will be using this to find certain types of files on our SAN such as PST files. If anyone could point me in the direction on how to use the

RUN Powershell Script in Docker Container From Host Powershell Script

落爺英雄遲暮 提交于 2021-02-07 08:11:12
问题 I have a powershell script in host which copy some files and starts the container. #Copy File docker cp "D:\addApplication.ps1" website:/inetpub/wwwroot/ #Start Container docker start website Write-Host 'Process has started' #Execute Container docker exec -ti website powershell #Run Script Invoke-Expression "C:\inetpub\wwwroot\addApplication.ps1" Second last command executes fine but last command will only execute when I exit the container session and returns error(File Not Found which is