Request for PowerShell gurus to look over my script before provided to the .NET 5 community

Hello,

I worked out a PowerShell script for publishing .NET 5 apps to one or more IIS servers. The script works, but I was wondering if some of the experts here would put an eye on the script and just see if any poor scripting practices present. This script will be provided to the .NET 5 community, and I'd like to make sure that it meets a decent level of quality.

The script is fairly simple: It just ...

  1. makes a session
  2. compresses the project
  3. moves the ZIP archive to the server
  4. decompresses it
  5. shuts down the website AppPool (required to avoid file locking issues)
  6. deletes the old project files
  7. copies the project files and folders to the right spot
  8. restarts the AppPool
  9. deletes the temporary files and folders
  10. continues for each server provided

https://github.com/GuardRex/net5-iis-ps-publish

Thanks!

September 11th, 2015 9:10pm

It looks good at a quick glance.

One suggestion is to move the script-block outside to the "if" to make the steering logic easier to see. I do this so I can easily keep track of implementation logic versus procedure.

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 9:19pm

Thanks jrv

I'm fighting with it on one issue: The ZIP file being moved exceeds the size limit allowed, so it throws a ...

Sending data to a remote command failed with the following error message: The current deserialized object size of the data received from the remote client computer exceeded the 
allowed maximum object size. The current deserialized object size is 10572800. 

So, I read that I can fix that with a config change, so I added this bit ...

Register-PSSessionConfiguration -Name DataNoLimits
Set-PSSessionConfiguration -Name DataNoLimits -MaximumReceivedDataSizePerCommandMB 500 -MaximumReceivedObjectSizeMB 500

and added -ConfigurationName DataNoLimits to the New_PSSession command

First, it complained with ...

dir : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. 

... and by hitting me with a popup that said something to the effect that the WMServ service was not running. I guess it restarted itself. That message went away on its own. Possibly the service went down when the file size crashed the connection or something.

It's moved to a new complaint now with that attempted config change ...

New-PSSession : [xxxxx.cloudapp.net] Connecting to remote server xxxxx.cloudapp.net failed with the following error message : The WS-Management service cannot process the 
request. Cannot find the DataNoLimits session configuration in the WSMan: drive on the xxxxx.cloudapp.net computer. For more information, see the about_Remote_Troubleshooting 
Help topic.

Luke





September 11th, 2015 10:10pm

Is that a question?

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 10:11pm

Looks like these commands ...

Register-PSSessionConfiguration -Name Microsoft.PowerShell
Set-PSSessionConfiguration -Name DataNoLimits -MaximumReceivedDataSizePerCommandMB 500 -MaximumReceivedObjectSizeMB 500

... need to be run locally and on the server.

But ... out of memory exception is next. I'll have to do something other than this for moving the ZIP file to the server.

September 11th, 2015 10:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics