powershell-3.0

Powershell to count columns in a file

放肆的年华 提交于 2020-07-10 11:11:54
问题 I need to test the integrity of file before importing to SQL. Each row of the file should have the exact same amount of columns. These are "|" delimited files. I also need to ignore the first line as it is garbage. If every row does not have the same number of columns, then I need to write an error message. I have tried using something like the following with no luck: $colCnt = "c:\datafeeds\filetoimport.txt" $file = (Get-Content $colCnt -Delimiter "|") $file = $file[1..($file.count - 1)]

Powershell to count columns in a file

荒凉一梦 提交于 2020-07-10 11:08:07
问题 I need to test the integrity of file before importing to SQL. Each row of the file should have the exact same amount of columns. These are "|" delimited files. I also need to ignore the first line as it is garbage. If every row does not have the same number of columns, then I need to write an error message. I have tried using something like the following with no luck: $colCnt = "c:\datafeeds\filetoimport.txt" $file = (Get-Content $colCnt -Delimiter "|") $file = $file[1..($file.count - 1)]

Powershell to count columns in a file

我的梦境 提交于 2020-07-10 11:08:02
问题 I need to test the integrity of file before importing to SQL. Each row of the file should have the exact same amount of columns. These are "|" delimited files. I also need to ignore the first line as it is garbage. If every row does not have the same number of columns, then I need to write an error message. I have tried using something like the following with no luck: $colCnt = "c:\datafeeds\filetoimport.txt" $file = (Get-Content $colCnt -Delimiter "|") $file = $file[1..($file.count - 1)]

Powershell to count columns in a file

醉酒当歌 提交于 2020-07-10 11:07:33
问题 I need to test the integrity of file before importing to SQL. Each row of the file should have the exact same amount of columns. These are "|" delimited files. I also need to ignore the first line as it is garbage. If every row does not have the same number of columns, then I need to write an error message. I have tried using something like the following with no luck: $colCnt = "c:\datafeeds\filetoimport.txt" $file = (Get-Content $colCnt -Delimiter "|") $file = $file[1..($file.count - 1)]

Powershell to count columns in a file

六月ゝ 毕业季﹏ 提交于 2020-07-10 11:07:12
问题 I need to test the integrity of file before importing to SQL. Each row of the file should have the exact same amount of columns. These are "|" delimited files. I also need to ignore the first line as it is garbage. If every row does not have the same number of columns, then I need to write an error message. I have tried using something like the following with no luck: $colCnt = "c:\datafeeds\filetoimport.txt" $file = (Get-Content $colCnt -Delimiter "|") $file = $file[1..($file.count - 1)]

Easier way to parse 'query user' in PowerShell

孤街醉人 提交于 2020-06-25 00:11:08
问题 I currently have the following query in PowerShell: query user /server:$server Which returns output: USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME svc_chthost 2 Disc 1:05 8/16/2016 12:01 PM myusername rdp-tcp 3 Active . 8/29/2016 11:29 AM Currently, I'm using @(query user /server:$server).Count - 1 as a value to represent the number of users logged on (it's not pretty, I know). However now I would like to obtain information such as USERNAME , ID , and LOGON TIME to use in other parts of

Power Shell CSV to AD

帅比萌擦擦* 提交于 2020-05-17 08:54:05
问题 Maybe someone can to help? I have a script it take parameters from scv and put them to AD, script work without mistakes but I`m does not have results from some reasone. Please help! Import-CSV -Path "$home\desktop\Scripts\test4.scv" | ForEach-Object -process {Write-Host $_ } {Set-ADuser|]= -Identity $_.DisplayName -extensionattribute5 $_.extensionattribute5} example scv 回答1: According to the docs, the -Identity parameter on Set-ADUser must be one of A distinguished name A GUID (objectGUID) A

Disable 'Bidirectional communication' for a printer?

随声附和 提交于 2020-05-17 06:44:28
问题 How do you disable 'Bidirectional communication' using powershell? I can see EnableBIDI when running: get-WmiObject -class Win32_printer | fl * But when I try this, it says the property was not found? Set-PrinterProperty -PrinterName "Some Printer" -PropertyName "EnableBIDI" -Value $False 回答1: You are mixing properties from two different WMI classes. Set-PrinterProperty manipulates instances of the undocumented MSFT_PrinterProperty class from the root/standardcimv2 namespace, which has

How to schedule a PS script in task scheduler which copies files from remote computer to local machine?

两盒软妹~` 提交于 2020-04-30 06:33:27
问题 My requirement was to copy certain files from remote machine to the local machine and I have written mapped the folder to the local machine.I use the drive letter of the mapped folder and the script works fine. But when I schedule the task, it throws error that the drive doesn't exists or isn't mapped. Please find the script below: $destination = "D:\Script\" $source = "T:\" $datefolders = Get-ChildItem $source $TodayString = (Get-Date).ToString("yyyy-MM-dd") foreach($folder in $datefolders)

Get count of all the subsites (all levels) in all site collections in SharePoint Online using PowerShell

筅森魡賤 提交于 2020-03-05 05:08:24
问题 I'm trying to get all site collections and respective subsites at all levels within the site collection using PowerShell. There are so many posts and references which outline the way but I could not find a post which can provide the count of subsites (all levels again) in a site collection. My environment is SharePoint Online. I need two things: Get the count of all subsites in all site collections in SharePoint Online and export to CSV. Export the list of site collections and subsites in the