According to the documentation for Invoke-Sqlcmd, you can use -verbose to display the output messages. From that post:
Example 5: Run a query and display verbose output
PS C:\> Set-Location "SQLSERVER:\SQL\MyComputer\MainInstance"
PS C:\> Invoke-SqlCmd -Query "PRINT N'abc'" -Verbose
I have bat file processes that use ...
Sorted it. Mapped the network share to the workspace of the SQL server using the code below
sp_configure 'show advanced options', '1'
sp_configure 'xp_cmdshell', '1'
set @cmd='net use P: \\XXX.XXZ.XYZ.010\backup\ Password /user:XXX.XXZ.XYZ.010\NASAccount';
exec master..xp_cmdshell @cmd, no_output;
Then you should be able to backup ...
the problem are not coming from the dba tools but from your network.
You can't mount a share on a local path. That path (K) can't be seen by sql server.
The unc path works with the user that is running the sql server service, in your case the computer account; but you can't authorise the compunter account in your nas under workgroup.
The only option i can ...
For the First question, I agree with the above post of @Kin Shah. For the second question, which means if we want to log the verbose message into a log file and PowerShell window, both the places then we can use tee-object like below:
invoke-sqlcmd -Query "PRINT 'Hello World'" -ServerInstance WL357044\SQL2017 -Database abc -Verbose *>&1| tee-...
For 1, you can use PowerShell redirection operators. As per Redirectable output streams, steam 4 is Verbose Stream which is what you want.
invoke-sqlcmd .... -verbose 4>> "D:\temp\yourlogfile.log"
Above will append all your invoke-sqlcmd into just one log file "D:\temp\yourlogfile.log"
your question part 2 is unclear to me.
Plase try to collect from msdb database the latest backup with a query like that: