Create a csv of file attributes recursively from a directory parameter in PowerShell

I’m a bit new to PowerShell and was wondering if there are any improvements I could make to the following script. Any suggestions for style, code, etc. are all welcome.

I’m not sure if there is a more efficient way of filtering the files by last modified date. I need to run it against 30 million files in batches of 500,000.

I’ve included an example of the UNC path that I use to produce the results file name in the $ tempArg variable based off of a folder name of the office location.

I’m currently running this script in a .bat file. Is there a better way of running this script concurrently?

PowerShell Script

$  filePathAttributes = "C:\Temp\*.*"  #$  args[0] $  tempArg = "\server\state$  \office name\documents\*.*" #An example of the path format $  folder = ($  tempArg).Substring(1, ($  tempArg).Length - 4) $  parent = Split-Path $  folder  $  office = Split-Path $  parent -Leaf $  office_format = $  office -replace '\W','-' $  filePathResults = "C:\Temp\Results_" + $  office_format + ".csv" $  linenumber = 1  Get-Childitem -recurse -Path $  filePathAttributes | ? {$  _.lastwritetime -gt '01-Jul-2018' -AND $  _.lastwritetime -lt '31-Mar-2019'} | ForEach-Object {    $  fullName = $  _.FullName   Get-Content $  fullName | Measure-Object -Line -Character -Word |     Select-Object -ExcludeProperty Property @{ Name  = 'FileID'; Expression={$  linenumber}}, @{ Name = 'ExtractTime'; Expression={ Get-Date -format "dd-MMM-yyyy HH:mm:ss.fff" }}, @{ Name = 'FullName'; Expression={ $  fullName }}, @{ Name  = 'FilePath'; Expression={ [System.IO.Path]::GetDirectoryName($  fullName) }}, @{ Name  = 'FileName'; Expression={ [System.IO.Path]::GetFileName($  fullName) }}, @{ Name  = 'FileSize'; Expression={ (Get-Item $  fullName).length / 1024 }}, @{ Name  = 'Attributes'; Expression={(Get-ItemProperty $  fullName).Attributes }}, @{ Name  = 'LastWriteTime'; Expression={(Get-ItemProperty $  fullName).LastWriteTime }}, @{ Name  = 'CreationTime'; Expression={(Get-ChildItem $  fullName).CreationTime }}, * ;$  linenumber ++ } | Export-Csv -NoTypeInformation -Path $  filePathResults 

Batch File Script

start powershell.exe C:\Temp\FileAttributes.ps1 "C:\Temp\*.*" start powershell.exe C:\Temp\FileAttributes.ps1 "C:\Temp1\*.*" start powershell.exe C:\Temp\FileAttributes.ps1 "C:\Temp2\*.*" 

Example of CSV file

screenshot

Actualizar Active Directory sobre Windows Server 2012 r2

Tengo montado un dominio de Active Directory sobre Windows Server 2012 r2 al que le voy añadiendo un servidor de sub-dominio por despacho/departamento.

El caso es que tras tener toda la estructura montada con 2012 r2, creo que ha llegado la hora de pasar a 2016 o 2019.

Y aquí viene mi duda.

Puedo empezar a utilizar 2016 o 2019 en los servidores de sub-dominio que vaya instalando nuevos aún teniendo montado el dominio sobre 2012 r2 para posteriormente ir cambiando todo o debo cambiar primero el DC para de ahí hacia abajo ir actualizando “en orden”.

Es algo a lo que le estoy dando vueltas y quiero sopesar todas las opciones antes de dar algún paso.

Muchas gracias de antebrazo.

Can’t enter directory despite correct permissions

I have a directory (Owned by nobody due to it being a part of a Docker bind mount, combined with user namespace remapping.) that I need to enter. This is its relevant ls -la output:

drwxrwxr-x    2 nobody   nobody        4096 May 26 14:42 Directory 

Running as root, although I don’t belong in either the owner or group of the directory, the directory is world readable and executable, so I should be able to enter it. However, when running cd Directory, it fails:

bash: cd: Directory: Permission denied 

No such file or directory when I execute ( hdfs namenode -format )

After setting everything on the CentOS server to run Hadoop. When I execute hdfs namenode -format I get this result:

hdfs namenode -format

/home/wael/hadoop/bin/hdfs: line 304: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/bin/java: No such file or directory

and the Java Home is:

echo $ JAVA_HOME

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64

update-alternatives –config java

There are 2 programs which provide ‘java’.

Selection Command

1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.221-2.6.18.0.el7_6.x86_64/jre/bin/java) *+ 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java)

Any Idea Please

file_put_contents – ISO 8601 date in filename returns failed to open stream: No such file or directory

I am trying to log errors to file using file_put_contents method.

I have tried the following code and it works:

file_put_contents(date("j-n-Y G:i").'.log', $  log, FILE_APPEND); 

But i want to name a file in ISO 8601 date format, like this:

file_put_contents(date("c").'.log', $  log, FILE_APPEND);  

But it returns the following error:

failed to open stream: No such file or directory 

threefry.h: No such file or directory in Docker?

I’m trying to create a docker container using rocker and a homebrew R package. I have no troubles installing my homebrew package on my desktop. Alas, when I try to install it in the container I get the following error:

2 -g  -c predict_rcpp.cpp -o predict_rcpp.o In file included from /usr/local/lib/R/site-library/dqrng/include/dqrng_distribution.h:26:0,                  from predict_rcpp.cpp:5: /usr/local/lib/R/site-library/dqrng/include/dqrng_generator.h:27:10: fatal error: threefry.h: No such file or directory  #include <threefry.h>           ^~~~~~~~~~~~ compilation terminated. /usr/lib/R/etc/Makeconf:176: recipe for target 'predict_rcpp.o' failed make: *** [predict_rcpp.o] Error 1 ERROR: compilation failed for package ‘SLPRcpp’ * removing ‘/usr/local/lib/R/site-library/SLPRcpp’ Warning message: In install.packages(pkgs = f, lib = lib, repos = if (isMatchingFile(f)) NULL else repos) :   installation of package ‘SLPRcpp_2.6.tar.gz’ had non-zero exit status  

I’m guessing I’m missing dependency but I’m not sure what it is. How can I debug this?

This is my Dockerfile:

FROM rocker/r-ubuntu:18.04  RUN apt-get update -qq && apt-get install -y \   #git-core \    #libcurl4-gnutls-dev \    #libssl-dev \    libxml2-dev \   librandom123-dev \   r-cran-bh \    r-cran-dplyr \    #r-cran-ggiraph \    r-cran-ggplot2 \    r-cran-glue \    r-cran-httr \    r-cran-magrittr \    r-cran-plumber \    r-cran-purrr \    r-cran-r6 \    r-cran-rcpp \    #r-cran-rcppArmadillo \    #r-cran-rcppEigen \    r-cran-readr \    r-cran-rstan \    r-cran-rstantools \    r-cran-scales \    #r-cran-stanHeaders \    r-cran-stringr \   r-cran-shiny \   r-cran-tidyr \   r-cran-dqrng  RUN install.r ggiraph RcppArmadillo RcppEigen StanHeaders   # Install SLPRcpp package COPY SLPRcpp_2.6.tar.gz /SLPRcpp_2.6.tar.gz RUN install.r SLPRcpp_2.6.tar.gz  

Any suggestions for how to fix this?

Exception in thread “main” java.lang.IllegalStateException: The driver executable is a directory: C:\Users\Micky\OneDrive\Desktop\chromedriver.exe

Exception in thread “main” java.lang.IllegalStateException: The driver executable is a directory: C:\Users\Micky\OneDrive\Desktop\chromedriver.exe at com.google.common.base.Preconditions.checkState(Preconditions.java:585) at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:148) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141) at org.openqa.selenium.chrome.ChromeDriverService.access$ 000(ChromeDriverService.java:35) at org.openqa.selenium.chrome.ChromeDriverService$ Builder.findDefaultExecutable(ChromeDriverService.java:159) at org.openqa.selenium.remote.service.DriverService$ Builder.build(DriverService.java:355) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at Demo.main(Demo.java:13)

Tried adding chromedriver as an environment variable, mapping it to its path. Checked that all required jars are present

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;

public class Demo {

public static void main(String[] args)  {     // TODO Auto-generated method stub      // cREATE DRIVER OBJECT FOR CHROME BROWSER     System.setProperty("webdriver.chrome.driver", "C:\Users\Micky\OneDrive\Desktop\chromedriver.exe");      WebDriver driver = new ChromeDriver();      driver.get("http://google.com");    } 

}

Expected – Google webpage should load. Actual – Exception in thread “main” java.lang.IllegalStateException: The driver executable is a directory: C:\Users\Micky\OneDrive\Desktop\chromedriver.exe at com.google.common.base.Preconditions.checkState(Preconditions.java:585) at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:148) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141) at org.openqa.selenium.chrome.ChromeDriverService.access$ 000(ChromeDriverService.java:35) at org.openqa.selenium.chrome.ChromeDriverService$ Builder.findDefaultExecutable(ChromeDriverService.java:159) at org.openqa.selenium.remote.service.DriverService$ Builder.build(DriverService.java:355) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at Demo.main(Demo.java:13)

Unable to mail from command-line – public/pickup: No such file or directory

Attempting to send mails using mail(1) from the macOS terminal shell results in the following message and the mail is not sent.

postdrop: warning: unable to look up public/pickup: No such file or directory 

I have checked for the directory where I think it should be and it’s there:

root# ls -ld /var/spool/postfix/public/pickup prw--w--w-  1 _postfix  _postdrop  0 Dec 31  2016 /var/spool/postfix/public/pickup 

I’ve read that Postfix is launched ephemerally to send mail but I don’t know how – I have no idea how Postfix is configured on macOS. I know Postfix from Linux but am unfamiliar with macOS.

I’d just like to fix this so my script can send email its output.

Pertinent system details:

  System Version: macOS 10.12.6 (16G29) (Sierra)   Kernel Version: Darwin 16.7.0 

100 Manually High PR Directory Submission for $10

Hi Welcome to My services I am SEO expert. I have experience 2 year. SEO is very important for your website. I will do manual submission for your business or site to most popular directory. After work done I will send you complete excel-sheet report with screenshots and submitted link. BENEFITS OF MY SERVICE I am very faster Submit in Right Category 100% Real and active link 100% Satisfaction guarantee 100 Free directory submission with in 1 days

by: shampa9397
Created: —
Category: Directory Submission
Viewed: 162