Hello I am trying to figure out how to set up an SQL Server Agent Process that will pick up a file that was created by the step and send an email with the attachment. The first step is below. Would I execute the send mail right after or another step? If so how do I would I go about it. Currently I just pick up the file and email it but we have multiple clients now / they want the file more often so I need to automate it.
Any direction or help on this would be great.
Declare #PeriodStart Datetime
Declare #PeriodEnd Datetime
SELECT #PeriodEnd = GetDate()
,#PeriodStart = dateadd(hour,-168,getdate())
;WITH outpQ
AS
(
SELECT 1 AS grpOrd, CAST(null AS VARCHAR(255)) AS posInGrp, 'A' AS Ord, CaseNumberKey, 'A|' + ClientsKey + '|' + CAST(BRTNumber AS VARCHAR(11)) + '|' + IsNull(replace(convert(char(10), CoverDate, 101), '/', ''), '') + '|' + IsNull(replace(convert(char(10), CoverDate, 101), '/', ''), '') + '|' + IsNull(ParcelNumber, '') + '|' + IsNull(AssessedBeg, '') + '|' + IsNull(AssessedDim, '') + '|' + IsNull(AbbrLegal, '') + '|' + IsNull(WaterFrom, '') + '|' + IsNull(WaterTo, '') + '|' + IsNull(Cast(WaterOpen AS VARCHAR(50)), '') + '|' + IsNull(TaxFrom, '') + '|' + IsNull(TaxTo, '') + '|' + IsNull(Cast(TaxOpen AS VARCHAR(50)), '') AS Extract
FROM newCityCollection.dbo.PropertyInformation
WHERE DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2
UNION ALL
SELECT 1 As grpOrd, null AS posInGrp, 'A1', A.CaseNumberKey, 'A1|' + '|' + '|' + B.LienNumber + '|' + IsNull(Cast(B.LienAmt AS VARCHAR(50)), '') + '|' + IsNull(replace(LienDate, '/', ''), '') + '|' + IsNull(B.LienReason, '') AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN newCityCollection.dbo.muniLiens B ON B.CaseNumberKey = A.CaseNumberKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2
UNION ALL
SELECT 2 AS grpOrd, CAST(C.InterestsKey AS VARCHAR(11)) AS posInGrp, 'B', A.CaseNumberKey, 'B|' + '|' + IsNull(C.First, '') + '|' + IsNull(C.Middle, '') + '|' + IsNull(C.Last, '') + '|' + IsNull(C.Alias, '') + '|' + IsNull(C.ComName, '') + '|' + IsNull(C.DocRel, '') + '|' + Cast(C.InterestsKey AS VARCHAR(11)) AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN newCityCollection.dbo.Interests C ON C.CaseNumberKey = A.CaseNumberKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2
UNION ALL
SELECT 2 AS grpOrd, CAST(C.InterestsKey AS VARCHAR(11)) AS posInGrp, 'B1', A.CaseNumberKey, 'B1|' + IsNull(FullAdd, '') + '|' + IsNull(D.City, '') + '|' + IsNull(D.State, '') + '|' + IsNull(D.Zip, '') AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN newCityCollection.dbo.Interests C ON C.CaseNumberKey = A.CaseNumberKey
JOIN newCityCollection.dbo.InterestAdd D ON D.CaseNumberKey = A.CaseNumberKey AND D.InterestsKey = C.InterestsKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2
UNION ALL
SELECT 2 AS grpOrd, CAST(C.InterestsKey AS VARCHAR(11)) AS posInGrp, 'B2', A.CaseNumberKey, 'B2|' + '|' + IsNull(E.SuitNumber, '') + '|' + Cast(E.BDate AS VARCHAR(11)) + '|' + IsNull(E.Chapter, '') + '|' + IsNull(E.VS, '') AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN newCityCollection.dbo.Interests C ON C.CaseNumberKey = A.CaseNumberKey
JOIN newCityCollection.dbo.Banks E ON E.CaseNumberKey = A.CaseNumberKey AND E.InterestsKey = C.InterestsKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2
UNION ALL
SELECT 3 As grpOrd3, null AS posInGrp, 'B3', A.CaseNumberKey, 'B3|' + '|' + F.DocType + '|' + IsNull(Cast(F.DocAmt AS VARCHAR(50)), '') + '|' + IsNull(replace(convert(char(10), DocDate, 101), '/', ''), '') + '|' + IsNull(replace(convert(char(10), RecDate, 101), '/', ''), '') + '|' + IsNull(F.DocID, '') + '|' + IsNull(F.Grantee,'') + '|' + IsNull(F.Grantor,'') + Cast(F.DocIDKey AS VARCHAR(11)) AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN newCityCollection.dbo.Documents F ON F.CaseNumberKey = A.CaseNumberKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2
UNION ALL
SELECT 4 AS grpOrd, null AS posInGrp, 'C', A.CaseNumberKey, 'C|' + IsNull(J.CType, '') + '|' + IsNull(J.plaintiffName,'') + '|' + IsNull(J.plaintiffAdd1, '') + '|' + IsNull(J.plaintiffCity, '') + '|' + IsNull(J.plaintiffState, '') + '|' + IsNull(J.plaintiffZip, '') + '|' + '|' + IsNull(J.defendantName, '') + '|' + IsNull(J.defendantAdd1, '') + '|' + IsNull(J.defCity, '') + '|' + IsNull(J.defState, '') + '|' + IsNull(J.defZip, '') + '|' + '|' + IsNull(J.Court, '') + '|' + IsNull(J.CaseID, '') + '|' + IsNull(J.JAmt, '') + '|' + IsNull(replace(convert(VarChar(10), JDate, 101), '/', ''), '') + '|' + IsNull(replace(convert(VARCHAR(10), revivedDate, 101), '/', ''), '') AS Extract
FROM newCityCollection.dbo.PropertyInformation A
JOIN Acme.new_judgment_system.dbo.selected_compiled_clean J ON J.CaseNumber = A.CaseNumberKey
WHERE A.DateFinished BETWEEN #PeriodStart AND #PeriodEnd AND ClientKey = 2 AND J.plaintiffName NOT IN (SELECT Plaintiff FROM newCityCollection.dbo.excluded_Plaintiffs)
)
--Extract data set into a table -- dump table in .txt with current date as part of name then delete that table
SELECT Extract INTO datadump FROM outpQ ORDER BY CaseNumberKey, grpOrd, posInGrp, Ord
DECLARE #FileName varchar(50),
#bcpCommand varchar(2000)
SET #FileName = REPLACE('D:\Argosy_import_'+CONVERT(char(8),GETDATE(),1)+'_0001.txt','/','')
SET #bcpCommand = 'bcp "SELECT Extract FROM datadump" QUERYOUT "'
SET #bcpCommand = #bcpCommand + #FileName + '" -U ******* -P *********** -T -c'
EXEC master..xp_cmdshell #bcpCommand
DROP table datadump
I added this after Drop Table Dump and it seems to work.
EXEC msdb.dbo.sp_send_dbmail
#recipients=N'******',
#body='Message Body',
#subject ='Import file for #PeriodStart',
#profile_name ='Mail',
#file_attachments ='D:Argosy_import_051713_0001.txt';
Related
I've been working on a script that imports CSV file, then depending on if some values are present, outputs contents in a specific format. Example:
#all 4 variations are similar, with the only difference being PasswordLastSet and LastLogonDate either present or not - they are in epoch format, so I compare them to 1, which works fine
$users = import-csv "C:\Users\username\Documents\filename.csv" -delimiter ";"
$body = foreach($_ in $users){
if($_.'PasswordLastSet' -lt 1){
if($_.'LastLogonDate' -lt 1){
#last logon and password are empty
'"' + $_."SamAccountName" + '"' + ':' + '{"DisplayName":' + '"' + $_."DisplayName" + '"' + ',"UserPrincipalName":' + '"' + $_."UserPrincipalName" + '"' + ',"BusinessCategory":' + '"' + $_."BusinessCategory" + '"' + ',"EmployeeType":' + '"' + $_."EmployeeType" + '"' + ',"LeaveOfAbsence":' + '"' + $_."LeaveOfAbsence" + '"' + ',"LineOfBusiness":' + '"' + $_."LineOfBusiness" + '"' + ',"Login":' + '"' + $_."Login".replace('\','\\') + '"' + ',"MultiFactorAuthentication":' + '"' + $_."2FA" + '"' + ',"DistinguishedName":' + '"' + $_."DistinguishedName".replace('\','\\') + '"' + ',"EmployeeNumber":' + '"' + $_."EmployeeNumber" + '"' + ',"Enabled":' + '"' + $_."Enabled" + '"' + '},'}
else{
#password empty, last logon present
'"' + $_."SamAccountName" + '"' + ':' + '{"DisplayName":' + '"' + $_."DisplayName" + '"' + ',"UserPrincipalName":' + '"' + $_."UserPrincipalName" + '"' + ',"BusinessCategory":' + '"' + $_."BusinessCategory" + '"' + ',"EmployeeType":' + '"' + $_."EmployeeType" + '"' + ',"LeaveOfAbsence":' + '"' + $_."LeaveOfAbsence" + '"' + ',"LineOfBusiness":' + '"' + $_."LineOfBusiness" + '"' + ',"Login":' + '"' + $_."Login".replace('\','\\') + '"' + ',"MultiFactorAuthentication":' + '"' + $_."2FA" + '"' + ',"DistinguishedName":' + '"' + $_."DistinguishedName".replace('\','\\') + '"' + ',"EmployeeNumber":' + '"' + $_."EmployeeNumber" + '"' + ',"LastLogonDate":' + '"' + $_."LastLogonDate" + '"' + ',"Enabled":' + '"' + $_."Enabled" + '"' + '},'}
}
else{
if($_.'LastLogonDate' -lt 1){
#password present, last logon empty
'"' + $_."SamAccountName" + '"' + ':' + '{"DisplayName":' + '"' + $_."DisplayName" + '"' + ',"UserPrincipalName":' + '"' + $_."UserPrincipalName" + '"' + ',"BusinessCategory":' + '"' + $_."BusinessCategory" + '"' + ',"EmployeeType":' + '"' + $_."EmployeeType" + '"' + ',"LeaveOfAbsence":' + '"' + $_."LeaveOfAbsence" + '"' + ',"LineOfBusiness":' + '"' + $_."LineOfBusiness" + '"' + ',"Login":' + '"' + $_."Login".replace('\','\\') + '"' + ',"MultiFactorAuthentication":' + '"' + $_."2FA" + '"' + ',"DistinguishedName":' + '"' + $_."DistinguishedName".replace('\','\\') + '"' + ',"EmployeeNumber":' + '"' + $_."EmployeeNumber" + '"' + ',"PasswordLastSet":' + '"' + $_."PasswordLastSet" + '"' + ',"Enabled":' + '"' + $_."Enabled" + '"' + '},'}
else{
#password and last logon present
'"' + $_."SamAccountName" + '"' + ':' + '{"DisplayName":' + '"' + $_."DisplayName" + '"' + ',"UserPrincipalName":' + '"' + $_."UserPrincipalName" + '"' + ',"BusinessCategory":' + '"' + $_."BusinessCategory" + '"' + ',"EmployeeType":' + '"' + $_."EmployeeType" + '"' + ',"LeaveOfAbsence":' + '"' + $_."LeaveOfAbsence" + '"' + ',"LineOfBusiness":' + '"' + $_."LineOfBusiness" + '"' + ',"Login":' + '"' + $_."Login".replace('\','\\') + '"' + ',"MultiFactorAuthentication":' + '"' + $_."2FA" + '"' + ',"DistinguishedName":' + '"' + $_."DistinguishedName".replace('\','\\') + '"' + ',"EmployeeNumber":' + '"' + $_."EmployeeNumber" + '"' + ',"PasswordLastSet":' + '"' + $_."PasswordLastSet" + '"' + ',"LastLogonDate":' + '"' + $_."LastLogonDate" + '"' + ',"Enabled":' + '"' + $_."Enabled" + '"' + '},'}
}
}
$output = "{" + $body
$output = $output.TrimEnd(',') + "}"
$output
$output | Out-File "$env:userprofile\Documents\filename.txt" -append -Encoding UTF8
The above code works as I want it to. The issue I have is with creating a loop to process (up to) 10 records from the CSV file.
I want it to go through 10 users, check the conditions and format output accordingly, then add "{", Trim the last comma and add "}", then go through another 10 users, considering that the last loop might have less than 10 users.
I've tried to write the loops myself, but any way I tried, something was wrong and I gave up for a while.
If something is unclear, let me know. Please excuse my unclear formatting.
I would really appreciate any help with this.
As per my comment, I would suggest looking into working with your data and converting it to Json through Convertto-Json instead of building your own.
That being said, here is a sample on how you could manage increments of 10 users.
You will need to adapt it to your need but it essentially process batch of 10 users and / or the remaining and allow you to add anything before, within and after the 10 users loop.
Example
$Users = 1..22
$sb = [System.Text.StringBuilder]::new()
$batchItemsCount = 10
for ($i = 0; $i -lt $Users.Count; $i += $batchItemsCount ) {
$MaxIndex = $i + $batchItemsCount - 1
if ($i + $batchItemsCount - 1 -gt $Users.Count ) { $MaxIndex = $Users.Count - 1 }
if ($i -eq 0) {
$sb.AppendLine('{') | Out-Null
} else {
$sb.AppendLine(',') | Out-Null
$sb.AppendLine('{') | Out-Null
}
# Your 10 users
foreach ($U in $users[$i..$MaxIndex]) {
# Insert your code here
$sb.AppendLine(" $U") | Out-Null
}
$sb.Append('}') | Out-Null
}
$sb.ToString()
Output
{
1
2
3
4
5
6
7
8
9
10
},
{
11
12
13
14
15
16
17
18
19
20
},
{
21
22
}
Note: I used a stringbuilder object, which is more performant than just manipulating string directly but you can replace the string builder statements by your strings directly if you are not comfortable with it.
I'm trying to loop through a series of txt files extracting information into arrays based a : delimiter.
All values i'm taking from the text files fit on a single line, except for one. (The "ad text" value). This cuts off the information after line 1 in the final output. When I remove line carriages and breaks beforehand, none of the fields are inputted correctly.
How would I specify wanting my array to accept multi-line inputs for the "ad text" field?
Below is the code i'm working with:
$files = ls "*.txt"
$dictionary = #{}
[System.Collections.Generic.List[String]]$list = #()
foreach($f in $files){$in = Get-Content $f
$in.Split([Environment]::NewLine) | ForEach-Object { $key,$value = $_.Split(':')
$dictionary[$key] = $value
}
[void]$list.Add( $dictionary['Ad ID'] + ',' + $dictionary['Ad Text'] + ',' + $dictionary['Ad Landing Page'] + ',' + $dictionary['Ad Targeting Location'] + ',' + $dictionary['Age'] + ',' + $dictionary['Language'] + ',' + $dictionary['Placements'] + ',' + $dictionary['Interests'] + ',' + $dictionary['Behaviors'] + ',' + $dictionary['Ad Impressions'] + ',' + $dictionary['Ad Clicks'] + ',' + $dictionary['Ad Spend'] + ',' + $dictionary['Ad Creation Date'] + ','+ $dictionary['Friends'] + ',' + $dictionary['Ad End Date'] + ',' + $dictionary['Excluded Connections'] + ',' + $dictionary['Image'] + ',' + $dictionary['Ad Targeting Location']+','+$dictionary[‘File Name’] )
}
$list | Out-File -FilePath '.\trial.csv' -Append
Assuming that the additional lines following Ad Text:-prefixed lines do not contain : chars themselves:
# Create sample text file t.txt
#'
Ad ID:10
Ad Text:one
two
Ad Landing Page:http://example.org
'# > t.txt
# Split the lines into field names and values by ":" and
# build a dictionary.
$dict = [ordered] #{}
$i = 0
(Get-Content -Raw t.txt) -split '(?m)^([^\n:]+):' -ne '' | ForEach-Object {
if ($i++ % 2 -eq 0) {
$key = $_
} else {
$dict[$key] = $_
}
}
# Output the dictionary, showing each entry as a list.
$dict | Format-List
The output is as follows, showing that the Ad Text entry comprises two lines:
Name : Ad ID
Value : 10
Name : Ad Landing Page
Value : http://example.org
Name : Ad Text
Value : one
two
I have a CSV file with delimiter as | , the values between the delimiter are not enclosed between quotes or any character. I am trying out a way to accept this file as an input and export a new CSV file with all the column to be enclosed in ^
Example:
Input:
1|Test|3
Output:
^1^|^Test^|^3^
Have tried below code but in vain:
get-content C:\ip.csv | foreach-object { $_ -replace '|' ,'^'} | set-content C:\op.csv
Try this:
$cont = get-content "D:\path\file.csv"
$cont | % {
$info = "^" + $_.Split("|")[0] + "^" + $_.Split("|")[1] + "^" + $_.Split("|")[2] + "^"
$info
}
I writing a script in Powershell to gather information about how many files are in my archive folder, the script is to count the files in the folder then it deletes file older than give date and then it counts the number of files again to report how many files it deleted.
I can get this to work however I am running into a little problem with the syntax. When I have it like this it works fine.
Clear-Host
$ErrorFiles = "c:\data\ErrorFiles"
$Archivefiles = "c:\data\Archivefiles"
$PreCountErrorFiles = ((Get-ChildItem $ErrorFiles | Measure-Object).Count)
$PreCountArchivefiles = ((Get-ChildItem $Archivefiles | Measure-Object ).Count)
Get-ChildItem $ErrorFiles | Where {$_.LastWriteTime –lt ((Get-Date).AddDays(-10) )} | ForEach { Remove-Item $_.FullName }
Get-ChildItem $Archivefiles | Where {$_.LastWriteTime –lt ((Get-Date).AddDays(-10) )} | ForEach { Remove-Item $_.FullName }
$PostCountErrorFiles = ((Get-ChildItem $ErrorFiles | Measure-Object).Count)
$PostCountArchivefiles = ((Get-ChildItem $Archivefiles | Measure-Object ).Count)
$str1 = "Number of files in " + $ErrorFiles.ToString() + " was " + $PreCountErrorFiles.ToString() + " number of files deleted " + ($PreCountErrorFiles - $PostCountErrorFiles).ToString() + " and " + $PostCountErrorFiles.ToString() + " are left." + "`n"
$str2 = "Number of files in " + $Archivefiles.ToString() + " was " + $PreCountArchivefiles.ToString() + " number of files deleted " + ($PreCountArchivefiles - $PostCountArchivefiles).ToString() + " and " + $PostCountArchivefiles.ToString() + " are left." + "`n"
write-host $str1
write-host $str2
However if I try to change the #str1 assignment to have it in one line and take both the strings I get this error (see code below)
Cannot convert value "Number of files in" to type "System.Int32". Error: "Input string was not in a correct format."
At line:13 char:1
+ $str1 = "Number of files in " + $ErrorFiles.ToString() + " was " + $PreCountErro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastFromStringToInteger
Clear-Host
$ErrorFiles = "c:\data\ErrorFiles"
$Archivefiles = "c:\data\Archivefiles"
$PreCountErrorFiles = ((Get-ChildItem $ErrorFiles | Measure-Object).Count)
$PreCountArchivefiles = ((Get-ChildItem $Archivefiles | Measure-Object ).Count)
Get-ChildItem $ErrorFiles | Where {$_.LastWriteTime –lt ((Get-Date).AddDays(-10) )} | ForEach { Remove-Item $_.FullName }
Get-ChildItem $Archivefiles | Where {$_.LastWriteTime –lt ((Get-Date).AddDays(-10) )} | ForEach { Remove-Item $_.FullName }
$PostCountErrorFiles = ((Get-ChildItem $ErrorFiles | Measure-Object).Count)
$PostCountArchivefiles = ((Get-ChildItem $Archivefiles | Measure-Object ).Count)
$str1 = "Number of files in " + $ErrorFiles.ToString() + " was " + $PreCountErrorFiles.ToString() + " number of files deleted " + ($PreCountErrorFiles - $PostCountErrorFiles).ToString() + " and " + $PostCountErrorFiles.ToString() + " are left." + "`n" +
- "Number of files in " + $Archivefiles.ToString() + " was " + $PreCountArchivefiles.ToString() + " number of files deleted " + ($PreCountArchivefiles - $PostCountArchivefiles).ToString() + " and " + $PostCountArchivefiles.ToString() + " are left." + "`n"
write-host $str1
Thanks for you help!
Remove the hyphen from the beginning of the second line:
$str1 = "Number of files in " + $ErrorFiles.ToString() + " was " + $PreCountErrorFiles.ToString() + " number of files deleted " + ($PreCountErrorFiles - $PostCountErrorFiles).ToString() + " and " + $PostCountErrorFiles.ToString() + " are left." + "`n" +
- "Number of files in " + $Archivefiles.ToString() + " was " + $PreCountArchivefiles.ToString() + " number of files deleted " + ($PreCountArchivefiles - $PostCountArchivefiles).ToString() + " and " + $PostCountArchivefiles.ToString() + " are left." + "`n"
^
In genereal, the format operator (-f) is a better approach to building strings like this:
$str1 = "Number of files in {0} was {1} number of files deleted {2} and {3} " +
"are left.`nNumber of files in {4} was {5} number of files deleted " +
"{6} and {7} are left.`n"
$str1 -f $ErrorFiles, $PreCountErrorFiles,
($PreCountErrorFiles - $PostCountErrorFiles),
$PostCountErrorFiles, $Archivefiles, $PreCountArchivefiles,
($PreCountArchivefiles - $PostCountArchivefiles),
$PostCountArchivefiles
I'm trying to move all the mails after removing the special characters in the filename to some destination based on the filename.
FOLDLIST is an array, where I'm having the condition variable and destination foldername.
Set-Location 'C:\Users\abrahame\Desktop\Work\PSG Mail Movement\Mail'
$DESLOC="c:\Temp\ua-closed bugs"
$FOLDLIST = #(("UA", "CLOSE", "ua-closed bugs"), ("VS", "CLOSE", "vs-closed-bugs"), ("CM", "CLOSED", "cm - closed-bugs"))
gci | Foreach-object { $NEWN = $_.Name -replace '&',' ' -replace '_', ' ' -replace '#', ' ' -replace '!', ' ' -replace '#', ' ' -replace '$', ' ' -replace '%', ' ' -replace '^', ' ' -replace '&', ' ' -replace '\(', ' ' -replace '\)', ' ' -replace '\[', ' ' -replace '\]', ' ' -replace '\{', ' ' -replace '\}', ' ' -replace '\-', ' ';
write-host $NEWN.Length
if($NEWN.Length -gt 70){
$NEWN="$NEWN.Substring(1,70)"
$NEWN=$NEWN.msg
}
$FOLDLIST | ForEach-Object {
$CXR=$_[0]
$STAT=$_[1]
if ($NEWN -match ("$CXR") -and $NEWN -match ("$STAT")){
write-host $CXR - $STAT
$DIR=$_[2]
$NEWN=$NEWN.trim()
$DPATH="$DESLOC\$DIR\$NEWN"
write-host $DPATH
mv $_.Name $DPATH
}
}
}
I'm getting this error. Please advise where I did mistake..
67
UA - CLOSE
c:\Temp\ua-closed bugs\ua-closed bugs\RE CLOSE OA TICKET 10350 OA UAT PHASE FOR HP FARES 1 .msg
Move-Item : Cannot bind argument to parameter 'Path' because it is null.
At C:\Users\abrahame\Desktop\Work\PSG Mail Movement\mailmove_multdimentional.ps1:24 char:5
+ mv <<<< $_.Name $DPATH
+ CategoryInfo : InvalidData: (:) [Move-Item], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.MoveItemCom
mand
My guess is that $_.Name does not exist.
If I were you, I'd bring the script into the ISE and run it line for line till you get there then take a look at the value of $_
$_ is the active object in the current pipeline. You've started a new pipeline with $FOLDLIST | ... so $_ represents the objects in that array that are passed down the pipeline. You should stash the FileInfo object from the first pipeline in a variable and then reference that variable later e.g.:
write-host $NEWN.Length
$file = $_
...
Move-Item $file.Name $DPATH
PM>Uninstall-Package EntityFramework -Force
PM>Iinstall-Package EntityFramework -Pre -Version 6.0.0
I solve this problem with this code in NugetPackageConsole.and it works.The problem was in the version.
i thikn it will help others.