dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.39k stars 787 forks source link

Issue with creating new directory when Invoke-DbaDbLogShipping. #9355

Closed xshen1 closed 1 month ago

xshen1 commented 1 month ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

VERBOSE: [16:01:28][Invoke-DbaDbLogShipping] Started log shipping for US00SSQL03 to US00SSQL02 VERBOSE: [16:01:28][Connect-DbaInstance] String is passed in, will build server object from instance object and other parameters, do some checks and then return the server object VERBOSE: [16:01:28][Connect-DbaInstance] authentication method is 'local integrated' VERBOSE: [16:01:28][Invoke-DbaDbLogShipping] Testing backup network path \US00SSQL03\Backup VERBOSE: [16:01:28][Connect-DbaInstance] String is passed in, will build server object from instance object and other parameters, do some checks and then return the server object VERBOSE: [16:01:28][Connect-DbaInstance] authentication method is 'local ad' VERBOSE: [16:01:29][Invoke-DbaDbLogShipping] Setting backup compression to 1. VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Destination database status set to NO RECOVERY VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup retention set to 4320 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup Threshold set to 60 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Copy retention set to 4320 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] History retention set to 14420 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore alert Threshold set to 45 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore delay set to 0 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore retention set to 4320 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore Threshold set to 45 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Primary monitor server security mode set to 1 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Secondary monitor server security mode set to 1 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup frequency relative interval set to Unused VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup frequency recurrence factor set to 0 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Copy frequency relative interval set to Unused VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Copy frequency recurrence factor set to 0 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore frequency relative interval set to Unused VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore frequency recurrence factor set to 0 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup start date set to 20240516 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup start time set to 000000 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Backup end time set to 235959 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Copy start date set to 20240516 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Copy start time set to 000000 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Copy end time set to 235959 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore start date set to 20240516 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore start time set to 000000 VERBOSE: [16:01:31][Invoke-DbaDbLogShipping] Restore end time set to 235959 VERBOSE: [16:01:31][Connect-DbaInstance] String is passed in, will build server object from instance object and other parameters, do some checks and then return the server object VERBOSE: [16:01:31][Connect-DbaInstance] authentication method is 'local integrated' VERBOSE: [16:01:32][Invoke-DbaDbLogShipping] Testing copy destination path \US00SSQL02\Backup VERBOSE: [16:01:32][Connect-DbaInstance] String is passed in, will build server object from instance object and other parameters, do some checks and then return the server object VERBOSE: [16:01:32][Connect-DbaInstance] authentication method is 'local ad' VERBOSE: [16:01:33][Invoke-DbaDbLogShipping] Backup local path set to W:\MSSQL14.MSSQLSERVER\MSSQL\Backup\AirWatch_DB10. VERBOSE: [16:01:33][Invoke-DbaDbLogShipping] Backup network path set to \US00SSQL03\Backup\AirWatch_DB10. VERBOSE: [16:01:33][Invoke-DbaDbLogShipping] Testing database backup network path \US00SSQL03\Backup\AirWatch_DB10 VERBOSE: [16:01:33][Connect-DbaInstance] String is passed in, will build server object from instance object and other parameters, do some checks and then return the server object VERBOSE: [16:01:33][Connect-DbaInstance] authentication method is 'local ad' VERBOSE: [16:01:34][Invoke-DbaDbLogShipping] Database backup network path \US00SSQL03\Backup\AirWatch_DB10 not found. Trying to create it.. VERBOSE: [16:01:34][Invoke-Command2] Creating backup folder \US00SSQL03\Backup\AirWatch_DB10 WARNING: [16:01:34][Invoke-DbaDbLogShipping] Something went wrong creating the backup directory | The FileSystem provider supports credentials only on the New-PSDrive cmdlet. Perform the operation again without specifying credentials. VERBOSE: [16:01:34][Invoke-DbaDbLogShipping] Finished setting up log shipping.

Steps to Reproduce

PS C:\Users\xishen> $params = @{ SourceSqlInstance = 'US00SSQL03' DestinationSqlInstance = 'US00SSQL02' Database = 'AirWatch_DB10' SharedPath= '\US00SSQL03\Backup' SourceCredential= 'SDAD\svcAnsibleSDAD' DestinationCredential= 'SDAD\svcAnsibleSDAD' LocalPath= 'W:\MSSQL14.MSSQLSERVER\MSSQL\Backup'

BackupScheduleFrequencyType = 'daily'
BackupScheduleFrequencyInterval = 1
BackupScheduleFrequencySubdayType = 'Minutes'
BackupScheduleFrequencySubdayInterval = 15

CopyScheduleFrequencyType = 'daily'
CopyScheduleFrequencyInterval = 1
CopyScheduleFrequencySubdayType = 'Minutes'
CopyScheduleFrequencySubdayInterval = 15

RestoreScheduleFrequencyType = 'daily'
RestoreScheduleFrequencyInterval = 1
RestoreScheduleFrequencySubdayType = 'Minutes'
RestoreScheduleFrequencySubdayInterval = 15

CompressBackup = $true
NoRecovery = $true
GenerateFullBackup = $true

SecondaryDatabaseSuffix = ''
CopyDestinationFolder = '\\US00SSQL02\Backup'

}

Invoke-DbaDbLogShipping @params

Please confirm that you are running the most recent version of dbatools

1.1.143

Other details or mentions

I think Powershell isnt happy with passing in credential to new-item anymore. is it possible to remove it or find a workaround? I tried to run the command without credential on https://github.com/dataplat/dbatools/blob/master/public/Invoke-DbaDbLogShipping.ps1#L929 and it worked correctly Screenshot 2024-05-16 at 4 45 38 PM

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.17763.5576
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.5576
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM-CU25) (KB5033688) - 15.0.4355.3 (X64) Jan 30 2024 17:02:22 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.4645.0

andreasjordan commented 1 month ago

This looks like a bug. I will provide a pull request for that, but I can not test it.